Conversational Inflow
One feature that the Java EE Connector Architecture specification is lacking at the moment is a way for the Enterprise Information System to have a "conversation" with the application server spanning multiple requests and responses. Status: Proof of concept stageState of the Union
Today the Java EE Connector Architecture specification allows a resource adapter to send a request to a MessageEndpoint through a MessageEndpointFactory that is configured with an ActivationSpec instance, and get a response back. If the MessageEndpoint supports transactions then the boundary of those are handled by the MessageEndpointFactory . This supports a single request-response scenario between the Enterprise Information System and the application server, with an optional transaction context. Example scenario: Messaging system triggering an Enterprise JavaBean Message Driven Bean (EJB/MDB)Brief overview: Inbound resource adapter
Description of feature
Conversational inflow will allow the Enterprise Information System to have an interaction with the application server that spans multiple requests / responses while optionally grouping the entire flow under a single transactional context. This would allow mapping a work flow inside the Enterprise Information System to a work flow executed in an application server context. In order to enable this interaction we need to extend the current Java EE Connector Architecture specification with new interfaces that defines the contract of these interactions. First, we need a ConversationalResourceAdapter interface that allows activation and deactivation of a ConversationalMessageEndpointFactory with an associated ActivationSpec instance.
ConversationalResourceAdapter
public void conversationActivation(ConversationalMessageEndpointFactory cmef, ActivationSpec as) throws ResourceException;
public void conversationDeactivation(ConversationalMessageEndpointFactory cmef, ActivationSpec as);
The
ConversationalMessageEndpointFactory
manage the
Conversation
instances.
public void conversationActivation(ConversationalMessageEndpointFactory cmef, ActivationSpec as) throws ResourceException;
public void conversationDeactivation(ConversationalMessageEndpointFactory cmef, ActivationSpec as);
ConversationalMessageEndpointFactory
public Conversation beginConversation(Serializable identifier) throws ResourceException;
public Conversation getConversation(Serializable identifier) throws ResourceException;
public Set<Serializable> activeConversations();
The
Conversation
controls an entire interaction between the Enterprise Information System and the
ConversationalMessageEndpoint
instance(s) deployed in the application server. The
Conversation
also defines the transactional boundary for the interaction.
The
Conversation
needs to support multiple endpoints of the same type, so a concrete instance is determined by a set of properties that the endpoint
is configured with.
public Conversation beginConversation(Serializable identifier) throws ResourceException;
public Conversation getConversation(Serializable identifier) throws ResourceException;
public Set<Serializable> activeConversations();
Conversation
public ConversationalMessageEndpoint createEndpoint(Class<?> endpoint, Map<Serializable, Serializable> properties, XAResource xares) throws ResourceException;
public Set<Map<Serializable, Serializable>> getProperties(Class<?> endpoint) throws ResourceException;
public boolean isDeliveryTransacted(Class<?> endpoint, Map<Serializable, Serializable> properties, Method method) throws ResourceException;
public Set<Class<?>> getEndpointClasses();
public void endConversation() throws ResourceException;
public void cancelConversation() throws ResourceException;
The
ConversationalMessageEndpoint
extends the current
MessageEndpoint
interface, with no new methods.
public ConversationalMessageEndpoint createEndpoint(Class<?> endpoint, Map<Serializable, Serializable> properties, XAResource xares) throws ResourceException;
public Set<Map<Serializable, Serializable>> getProperties(Class<?> endpoint) throws ResourceException;
public boolean isDeliveryTransacted(Class<?> endpoint, Map<Serializable, Serializable> properties, Method method) throws ResourceException;
public Set<Class<?>> getEndpointClasses();
public void endConversation() throws ResourceException;
public void cancelConversation() throws ResourceException;
Example
The ZIP file contains an example of a simple conversation pattern between an Enterprise Information System and the application server. There are 5 different message types from the Enterprise Information System:- "A": Start a conversation with the supplied conversation identifier
- "B": Send a message to endpoint "B" identified by the supplied conversation identifier
- "C": Send a message to endpoint "C" identified by the supplied conversation identifier
- "D": End a conversation with the supplied conversation identifier
- "E": Cancel a conversation with the supplied conversation identifier
Example overview:
ConversationalTestCase.java - JUnit test case
cra/ConversationalResourceAdapterImpl.java - Conversational resource adapter implementation
cra/inflow/ConversationalActivation.java - Interaction with the Enterprise Information System
cra/inflow/ConversationalActivationSpec.java - The activation specification
cra/inflow/ConversationalMessageListener.java - The message listener interface
spi/ConversationalResourceAdapter.java - New ConversationalResourceAdapter interface
spi/conversation/Conversation.java - New Conversation interface
spi/conversation/ConversationalMessageEndpoint.java - New ConversationalMessageEndpoint interface
spi/conversation/ConversationalMessageEndpointFactory.java - New ConversationalMessageEndpointFactory interface
support/ConversationImpl.java - Example conversation implementation
support/ConversationalMessageEndpointFactoryImpl.java - Example conversational message endpoint factory implementation
support/ConversationalMessageEndpointImpl.java - Example conversational message endpoint implementation
Note, that the example is not meant to be 100% complete, so there may be bugs, and missing cases :)
cra/ConversationalResourceAdapterImpl.java - Conversational resource adapter implementation
cra/inflow/ConversationalActivation.java - Interaction with the Enterprise Information System
cra/inflow/ConversationalActivationSpec.java - The activation specification
cra/inflow/ConversationalMessageListener.java - The message listener interface
spi/ConversationalResourceAdapter.java - New ConversationalResourceAdapter interface
spi/conversation/Conversation.java - New Conversation interface
spi/conversation/ConversationalMessageEndpoint.java - New ConversationalMessageEndpoint interface
spi/conversation/ConversationalMessageEndpointFactory.java - New ConversationalMessageEndpointFactory interface
support/ConversationImpl.java - Example conversation implementation
support/ConversationalMessageEndpointFactoryImpl.java - Example conversational message endpoint factory implementation
support/ConversationalMessageEndpointImpl.java - Example conversational message endpoint implementation