3.16.3 Message inflow

A message inflow is a contract between the resource adapters and Message-driven Beans. The resource adapters complying with the Connector 1.5 specifications can receive messages from the message providers such as EIS, and operate the message endpoint (Message-driven Bean) on Application Server. The message endpoint asynchronously processes the messages sent from the message provider.

You can use the following two message delivery methods with Application Server:

The difference in the methods is the participation of the invocation source EIS in the transaction.

Organization of this subsection
(1) Preconditions
(2) Procedure for controlling the message inflow (for a Non-Transacted Delivery)
(3) Procedure for controlling the message inflow (for a Transacted Delivery)
(4) Deploying and undeploying the message endpoint

(1) Preconditions

The message inflow is enabled when the resource adapters and Message-driven Beans satisfy the following conditions:

Also, a Transacted Delivery is enabled when the conditions described in the following table are satisfied.

Table 3-68 Conditions when a Transacted Delivery is enabled

J2EE server settingsMessage-driven Bean settings
Transaction management type <transaction-type> is ContainerTransaction management type <transaction-type> is Bean
Transaction attribute <trans-attribute> is RequiredTransaction attribute <trans-attribute> is NotSupported
ejbserver.distributedtx.XATransaction.enabledtrueYNN
falseRNN
Legend:
Y: The EIS delivering the message is included in the global transaction and then the transaction is started.
R: The EIS delivering the message is not included in the transaction and the local transaction is started.
N: The transaction is not started.

Also, to use a Transacted Delivery, you must use resource adapters conforming to the Connector 1.5 specifications and supporting Transacted Delivery. For details on the settings, see the documentation for the resource adapter in use.

(2) Procedure for controlling the message inflow (for a Non-Transacted Delivery)

A Non-Transacted Delivery is a message delivery in which the EIS that delivers the messages does not participate in the transaction.

The following figure shows the control procedure when the message inflow is used with a Non-Transacted Delivery.

Figure 3-49 Control procedure when the message inflow is used with a Non-Transacted Delivery

[Figure]

The following points describe the control executed when the message inflow is used with a Non-Transacted Delivery. Note that the item numbers correspond to the numbers in the figure.

  1. The properties are set up in ActivationSpecJavaBean of the resource adapter by the application start processing.
    The content specified in the Message-driven Bean attribute <activation-config> is set up.
  2. The J2EE server invokes the endpointActivation method. As a result, the starting of the message endpoint is reported to the resource adapter.
  3. The EIS sends a message.
  4. The resource adapter invokes the createEndpoint message for MessageEndpointFactory.
  5. MessageEndpointFactory generates an endpoint proxy.
  6. The resource adapter invokes a message listener method, such as the onMessage method, for the endpoint proxy.
  7. The endpoint proxy invokes a message listener method, such as the onMessage method, for the Message-driven Bean.
  8. When the processing is complete, the J2EE server invokes the endpointDeactivation method. As a result, the stopping of message endpoint is reported to the resource adapter.

(3) Procedure for controlling the message inflow (for a Transacted Delivery)

A Transacted Delivery is a message delivery in which the EIS that delivers the messages participates in the transaction.

The following figure shows the control procedure when the message inflow is used with a Transacted Delivery.

Figure 3-50 Control procedure when the message inflow is used with a Transacted Delivery

[Figure]

The following points describe the control executed when the message inflow is used with a Transacted Delivery. Note that the item numbers correspond to the numbers in the figure.

  1. The properties are set up in ActivationSpecJavaBean of the resource adapter by the application start processing.
    The content specified in the Message-driven Bean attribute <activation-config> is set up.
  2. The J2EE server invokes the endpointActivation method. As a result, the starting of the message endpoint is reported to the resource adapter.
  3. The EIS sends a message.
  4. The resource adapter invokes the createEndpoint message for MessageEndpointFactory.
  5. MessageEndpointFactory generates an endpoint proxy.
  6. The resource adapter invokes a message listener method, such as the onMessage method, for the endpoint proxy.
  7. The invoked endpoint proxy invokes a start transaction instruction for the transaction manager.
  8. The transaction manager invokes the start method and starts the transaction.
  9. The endpoint proxy invokes a message listener method, such as the onMessage method, for the Message-driven Bean.
  10. The endpoint proxy instructs the conclusion of the transaction to the transaction manager.
  11. The transaction manager invokes the transaction conclusion methods, such as the prepare method and commit method, to conclude the transaction.
  12. When the processing is complete, the J2EE server invokes the endpointDeactivation method. As a result, the stopping of message endpoint is reported to the resource adapter.

(4) Deploying and undeploying the message endpoint

This section describes the processing executed for deploying and undeploying the message endpoint.

Deploying the message endpoint

This section describes the processing executed for deploying the message endpoint. The message endpoint is deployed when you start an application containing the Message-driven Beans when the resource adapter is running.

The following figure shows the processing for deploying the message endpoint.

Figure 3-51 Processing for deploying the message endpoint

[Figure]

The following points describe the processing executed for deploying the message endpoint. The item numbers correspond to the numbers in the figure.

  1. Start the J2EE application containing the Message-driven Beans when the resource adapter is running.
  2. The J2EE server generates MessageEndpointFactory.
    MessageEndpointFactory is an instance of javax.resource.spi.endpoint.MessageEndpointFactory provided by the J2EE server. javax.resource.spi.endpoint.MessageEndpointFactory is a factory class that provides an endpoint instance to the resource adapter.
  3. The J2EE server generates ActivationSpec.
    ActivationSpec is a JavaBean that sets up the information required for starting the Message-driven Beans (endpoint).
  4. The J2EE server sets up the ActivationSpec property.
    The information specified in the ActivationSpec property is set up as an attribute of the application that contains the Message-driven Beans.
  5. The J2EE server invokes the javax.resource.spi.ResourceAdapter#endpointActivation(MessageEndpointFactory, ActivationSpec) method.
    At this time, the generated and set up MessageEndpointFactory and ActivationSpec instances are specified as arguments. Note that if an exception occurs during the invocation of the endpointActivation method, the KDJE43174-E message is output and the starting of the application is canceled.
  6. If the method specified in 5 is invoked, the resource adapter prepares to receive the messages from the message provider.
Undeploying the message endpoint

This section describes the processing executed for undeploying the message endpoint. The message endpoint is undeployed when you stop an application containing the Message-driven Beans.

The following figure shows the processing for undeploying the message endpoint.

Figure 3-52 Processing for undeploying the message endpoint

[Figure]

The following points describe the processing executed for undeploying the message endpoint. The item numbers correspond to the numbers in the figure.

  1. Stop the J2EE application containing the Message-driven Beans.
  2. The J2EE server invokes javax.resource.spi.ResourceAdapter#endpointDeactivation(MessageEndpointFactory, ActivationSpec).
    At this time, the same MessageEndpointFactory and ActivationSpec instances, which were specified for deployment, are specified as arguments. Note that if an exception occurs during the invocation of this method, the message KDJE43175-W is output. However, even if an exception occurs, the application stop processing continues.
  3. If the method specified in 2 is invoked, the resource adapter executes the processing to terminate the receiving of messages from the message provider.
Processing of the resource adapter for delivering the messages

This section describes the processing of the resource adapter for delivering the messages.

The resource adapter invokes the message endpoint (Message-driven Bean) by using the message endpoint proxy. This proxy is obtained by invoking the createEndpoint method of javax.resource.spi.endpoint.MessageEndpointFactory from the resource adapter.

Note
  • If you invoke the MessageEndpointFactory method after the application stops, the javax.resource.spi.UnavailableException exception is thrown. At this time, the message KDJE43177-E is output. Also, when the message endpoint method is invoked, the java.lang.IllegalStateException exception is thrown. At this time, the message KDJE43177-E is output.
  • In a Transacted Delivery, if you stop a J2EE application during message delivery, the transaction might be rolled back. At this time, KDJE31011-E or KDJE31012-E error might occur. These errors might also occur when you stop the running J2EE application when the J2EE server is stopped.