Example 4: Automatically stopping an MDB when no exception destination is specified

To prepare for a system resource becoming unavailable or a problem message, configure the system to stop the message-driven bean (MDB) automatically. To maintain message ordering, do not use an exception destination.

Before you begin

This task assumes that you have deployed an enterprise application containing a message-driven bean (MDB) that interacts with external system resources.

The destination to which the MDB listens must not use an exception destination, that is, the exception destination for the queue or topic space destination must be configured as none.

To complete this task, you need the following information:
  • The enterprise application that contains the MDB.
  • The dependent external system resources.
  • A value of 1 for the Limite de mensagem com falha sequencial. This is the maximum number of sequential failures of delivery of messages, after which the MDB is stopped. This property applies to sets of messages.
    Note: If this property is set to a value greater than 1, the system automatically resets it to 1 when an exception destination is configured as none.
  • A value of 5000 for the Atraso entre novas tentativas de mensagem com falha, that is, the time in milliseconds before a failing message is available to be delivered to the MDB. Other messages might be delivered during this period, unless theLimite de mensagem com falha sequencial and the maximum concurrency is set to 1.
  • An acceptable value for the Máximo de entregas com falha por mensagem, that is, the maximum number of failed attempts to process a message. This property applies to individual messages.

The JCA MBean emits JMX notifications to indicate that the MDB is paused, and that the MDB has resumed. Consider registering a message listener on the JCA MBean to receive the JMX notifications.

About this task

In this scenario, the enterprise application is a continuously running system that uses a deployed MDB to access an external system resource.

When a problem message (msg1 in this scenario) is encountered, it is put back on the queue.

Instead of msg1 being made available to the MDB immediately, it is hidden for the Atraso entre novas tentativas de mensagem com falha retry delay (five seconds in this scenario).

When the number of hidden messages reaches the Limite de mensagem com falha sequencial, the MDB will not process any further messages until one of the hidden messages becomes re-available. In this scenario, this threshold is reached as soon as msg1 is hidden.

When the Atraso entre novas tentativas de mensagem com falha for msg1 expires, msg1 is unhidden and reprocessed.

This process is repeated until msg1 reaches its Máximo de entregas com falha por mensagem limit (five times in this scenario).

After msg1 is unhidden for the fourth time, rolled back and rehidden, the Limite de mensagem com falha sequencial is reached and the MDB stops automatically. A JMX notification is emitted by the JCA MBean and a log entry alerts the system administrator that the MDB has stopped.

Procedure

  1. Navigate to the deployed enterprise application that contains the MDB.
  2. From the MDB, navigate to its JMS activation specification. Click Recursos -> JMS -> Especificações de ativação -> activation_specification_name.
  3. Enter a value of 1 for the Limite de mensagem com falha sequencial.
  4. Enter a value of 5000 for the Atraso entre novas tentativas de mensagem com falha.
  5. Save the configuration.
  6. Navigate to the destination to which the MDB is listening. Click one of the following paths, as appropriate:
    • Integração de serviços -> Barramentos -> bus_name -> [Recursos de destino] Destinos -> queue_name
    • Integração de serviços -> Barramentos -> bus_name -> [Recursos de destino] Destinos -> topic_space_name
  7. Under Destino de Exceção, select Nenhum.
  8. Enter a value of 5 in Máximo de entregas com falha por mensagem.
  9. Salve suas alterações na configuração principal.
  10. When you receive a JMX notification and a log entry indicating that the MDB (or endpoint) has been paused, investigate the problem with the system resource that the MDB was using. While the MDB is paused, because no exception destination is configured, msg1 remains on the queue. No other messages are processed.
  11. If you resume the MDB but the problem with the failing message continues, the maximum failed deliveries limit is reached on the first retry of the message, but because no exception destination is configured, the message is not moved to another queue. Instead, the whole queue point is blocked to all consumers for the Atraso entre novas tentativas de mensagem com falha retry delay interval (five seconds in this scenario). After this time, consumers begin again. If the failing message is still there, and fails again, the queue point is blocked for another 5 seconds. This process continues until you remove the failing message from the queue, either by deleting it manually or solving the problem with it, and in doing so allowing the consuming application to succeed in processing.
  12. Log on to the administrative console again, navigate to the same enterprise application and click Resume on the administrative panel for the MDB. You can also resume the MDB by using scripting and the JCA MBean. The initial JMX notification and log entry indicate which MBean to use to resume the MDB. The MDB begins to be driven with the messages that are on the destination.

Results

You have configured the system to protect itself from external resource failures while maintaining message ordering.

What to do next

When the MDB is resumed, the JCA MBean emits a JMX notification to indicate that the MDB has resumed. Messages on the queue are consumed, messages that had failed are retried, and the transaction commits.

Ícone que indica o tipo de tópico Tópico de Tarefa



Ícone de registro de data e hora Última atualização: July 9, 2016 7:55
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tjn_mdb_0001_Ex4
Nome do arquivo: tjn_mdb_0001_Ex4.html