-
1. Re: jboss7.1 configured with hornetq JMS error queue
jbertram Nov 9, 2012 5:23 PM (in response to mathewvino)The exact process is different depending on what kind of client you are using (e.g. MDB, stand-alone JMS client, core client, etc.), but basically you need to consume the message transactionally and if you have an error then rollback the transaction and that will send the message back to the destination it came from.
-
2. Re: jboss7.1 configured with hornetq JMS error queue
mathewvino Nov 9, 2012 5:46 PM (in response to jbertram)Thanks Justin for the quick reply
I am using the Spring JMS Client configured through Spring xml file . May be I am dumb:) How do i Consume the message trnasactionally, Is is some setting /configuring the xml file
Please find the spring configuration i am using org.springframework.jms.core.JmsTemplate to publish the event.
Thanks for the help
****************** configration in spring xml file ********************************
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop>
<prop key="java.naming.provider.url">remote://localhost:4447</prop>
<prop key="java.naming.security.principal">guest</prop>
<prop key="java.naming.security.credentials">pass</prop>
</props>
</property>
</bean>
<bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName">
<value>jms/RemoteConnectionFactory</value>
</property>
</bean>
<bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName">
<value>jms/tfnQueueEvents</value>
</property>
</bean>
<bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="cache">
<value>true</value>
</property>
</bean>
<bean id="queueTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="queueConnectionFactory" />
</property>
<property name="destinationResolver">
<ref bean="jmsDestinationResolver" />
</property>
<property name="pubSubDomain" value="false"/>
<property name="defaultDestination" ref="destination"/>
<property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE"/>
</bean>
<bean id="jmsQueueEventPublisher" class="com.xxx.xxx.core.jms.event.JMSQueueEventPublisher">
<property name="jmsTemplate"
ref ="queueTemplate" />
</bean>
****************** configration in spring xml file ends ********************************
Publisher code starts from here ***********************
public class JMSQueueEventPublisher {
private static final Logger logger = LoggerFactory.getLogger(JMSQueueEventPublisher.class);
private JmsTemplate jmsTemplate;
public JmsTemplate getJmsTemplate() {
return jmsTemplate;
}
public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}
/**
* @param TfnEventVO
* Sets the message in the Queue
*/
public void sendMessage(final Collection<String> tfnList)
throws Exception {
logger.info("sendMessage CALLED" + this.jmsTemplate);
this.jmsTemplate.send(new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
logger.info("PUBLISH SESSSION -------" + session);
ObjectMessage message = session.createObjectMessage();
message.setStringProperty("username", "xxxxx");
long time = new Date().getTime();
message.setLongProperty("timestamp", new Timestamp(time).getTime());
message.setObject((Serializable) tfnList);
logger.info("PUBLISH message --------" + message);
return message;
}
});
}
}
-
3. Re: jboss7.1 configured with hornetq JMS error queue
jbertram Nov 9, 2012 5:54 PM (in response to mathewvino)You'll have to consult the Spring documentation for your answer as I'm not terribly familiar with their JmsTemplate.
-
4. Re: jboss7.1 configured with hornetq JMS error queue
jbertram Nov 9, 2012 6:00 PM (in response to mathewvino)BTW, it's the configuration of the consumer that is relevant, not the configuration of the producer (which you've shared here).
-
5. Re: jboss7.1 configured with hornetq JMS error queue
mathewvino Nov 9, 2012 6:14 PM (in response to jbertram)Thanks justin for helping me out. Here is the producer configuration
<bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="cache">
<value>true</value>
</property>
</bean>
<bean id="queueErrorTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="queueConnectionFactory" />
</property>
<property name="destinationResolver">
<ref bean="jmsDestinationResolver" />
</property>
<property name="pubSubDomain" value="false"/>
<property name="defaultDestination" ref="receiverDestination"/>
<property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE"/>
</bean>
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop>
<prop key="java.naming.provider.url">${environment.jmsserver}</prop>
<prop key="java.naming.security.principal">guest</prop>
<prop key="java.naming.security.credentials">pass</prop>
</props>
</property>
</bean>
<bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>jms/RemoteConnectionFactory</value>
</property>
</bean>
<bean id="receiverDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName">
<value>jms/tfnQueueEvents</value>
</property>
</bean>
<!-- this is the Message Driven POJO (MDP) -->
<bean id="messageListener" class="com.xxx.xxx.core.jms.listener.QueueEventListener">
<property name="jmsTemplate" ref="queueErrorTemplate" />
</bean>
<bean id="jmsContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="concurrentConsumers" value="1" />
<property name="connectionFactory" ref="queueConnectionFactory" />
<property name="destination" ref="receiverDestination" />
<property name="messageListener" ref="messageListener" />
<property name="sessionTransacted" value="true"/>
<property name="receiveTimeout" value="60000" />
</bean>
-
6. Re: jboss7.1 configured with hornetq JMS error queue
jbertram Nov 9, 2012 9:18 PM (in response to mathewvino)I'm not sure what you want me to do with this. As I indicated previously, I'm not terribly familiar with Spring. You need to consult the Spring documentation yourself and figure this out.