Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The JMS binding supports multiple wire formats including object serialization, JMS message types, and JAXB serialization. If a parameter type is annotated with the JAXB @XmlRootElement annotation, parameters will be sent as XML using a JMS text message. Otherwise, the JMS binding will introspect the parameter types and select the most appropriate message type (e.g. object, bytes, etc).

Transacted Messaging

Fabric3 supports XA transacted messaging. This is useful when a message must be reliably sent in conjunction with a database update. To enable transacted messaging, use the transactedOneWay intent on the JMS binding:

Code Block
xml
xml

<component name="TheComponent">
   <implementation.java class="..."/>
   <reference name="service">
      <binding.jms requires="transactedOneWay">
         <destination jndiName="TheQueue"/>
      </binding.jms>
   </reference>
</component>

The above will enqueue a message transactionally with the message provider. The component implementation is as follows:

Code Block
java
java

public class TheComponent implements ... {
   
   @Reference
   protected Service service;

   public void operation() {
      Message message = ...
      service.invoke(message);
   }

} 

If the above implementation also needed to update a database using Hibernate in the same transaction as the message enque, it could be modified as follows to use the @ManagedTransaction annotation:

Code Block
java
java

@ManagedTransaction
public class TheComponent implements ... {

   @PersisitenceContext(unitName = "employee")
   Session session;

   @Reference
   protected Service service;

   public void operation() {
      Message message = ...
      long id = message.getId();

      Entity entity = session.find(Entity.class, id);
      entity.update(message.getUpdate());
      service.invoke(message);
   }
} 
Info
titleTransacted Messaging and Request-Response

In a word: don't try it. Transacted messaging will not work with request reply. To see why, consider the following:

Code Block
java
java

@ManagedTransaction
public class TheComponent implements ... {

   @Reference
   protected Service service;

   public void operation() {
      Message message = ...
      Response response = service.invoke(message);
   }
} 

The forward transaction will not commit until after the response is received and the operation() method has returned. However, the outgoing message will not be enqueued until the transaction commits. This means that the message can not be sent and consequently a response will never be received. The result will be a message timeout.

Code Block
xml
xml

<component name="AsyncClientService">
   <implementation.java class="..."/>
   <reference name="service">
      <binding.jms requires="transactedOneWay">
         <destination jndiName="TheQueue"/>
      </binding.jms>
            <callback>
                <binding.jms requires="transactedOneWay">
                    <destination jndiName="asyncClientServiceCallbackQueue"/>
                </binding.jms>
            </callback>
        </reference>
    </component>

---> don't use request response --> onl one way

Service Auto Scaling

Fabric3 supports autoscaling where the number of message listeners for a service endpoint are dynamically resized based on workload. The following are the autoscaling attributes which can be configured per endpoint as attributes on binding.jms:

idle.limit
transaction.timout
receive.timeout
max.messages
recovery.interval
max.receivers
min.receivers