activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fan Li" <fangle...@gmail.com>
Subject Fwd: code change request
Date Thu, 09 Mar 2006 02:46:24 GMT
 For my previous change request with regards to the setTopicConnection and
setQueueConnection method in JmsMesageConvertor, it is probably better to
have just one setConnection method.

public void setConnection(Connection connection);

---------- Forwarded message ----------
From: Fan Li <fangleria@gmail.com>
Date: Mar 8, 2006 12:26 PM
Subject: Fwd: code change request
To: activemq-dev@geronimo.apache.org

that was not easy to read, try this again

---------- Forwarded message ----------
From: Fan Li <fangleria@gmail.com >
Date: Mar 8, 2006 12:19 PM
Subject: code change request
To: activemq-dev@geronimo.apache.org

Hi:

I am writing some code using the org.apache.activemq.network.jms package. In
particular, I am writing my own implementation of JmsConnector. I noticed
that the package currently does not support replyTo Destinations for
outbound message (see JmsTopicConnector.createReplyToBridge), but I think
this feature is necessary to have.

In order to handle replyTo Destinations for outbound message, a couple of
changes are need:

1. add a method to interface JmsMesageConvertor

public Message convert(Message message, Destination replyTo) throws
JMSException;

2. the DestinationBridge onMessage method also need to be changed slightly

original implementation:
public void onMessage(Message message){

if(started.get()&&message!=null){

                                try{

                                                if(doHandleReplyTo){

                                                                Destination
replyTo=message.getJMSReplyTo();


if(replyTo!=null){


replyTo=processReplyToDestination(replyTo);


message.setJMSReplyTo(replyTo);

                                                                }

                                                }else {


message.setJMSReplyTo(null);

                                                }

                                                Message converted=
jmsMessageConvertor.convert(message);

                                                sendMessage(converted);

                                                message.acknowledge();

                                }catch(JMSException e){

                                                log.error("failed to forward
message: "+message,e);

                                                try{

                                                                stop();

                                                }catch(Exception e1){

                                                               
log.warn("Failed
to stop cleanly",e1);

                                                }

                                }

                }

}

changed implementation
public void onMessage(Message message){

                if(started.get()&&message!=null){

                                try{

                                                Message converted;

                                                if(doHandleReplyTo){

                                                                Destination
replyTo = message.getJMSReplyTo();

                                                                if(replyTo
!= null){


converted = jmsMessageConvertor.convert(message,
processReplyToDestination(replyTo));

                                                                } else {


converted = jmsMessageConvertor.convert(message);

                                                                }

                                                } else {


message.setJMSReplyTo(null);

                                                                converted =
jmsMessageConvertor.convert(message);

                                                }


                                                sendMessage(converted);

                                                message.acknowledge();

                                }catch(JMSException e){

                                                log.error("failed to forward
message: "+message,e);

                                                try{

                                                                stop();

                                                }catch(Exception e1){

                                                               
log.warn("Failed
to stop cleanly",e1);

                                                }

                                }

                }

}



These changes are needed because setting JMSReplyTo header to
TemporaryDestination of another JMS implementation may throw exception.

Also, I think it is better for the JmsMesageConvertor to use the Connections
of the JmsConnector it associates with, rather than creating its own
Connections, so I am wondering if it is possible to add the following two
methods to the JmsMesageConvertor interface:

public void setTopicConnection(TopicConnection connection);

public void setQueueConnection(QueueConnection connection);



Thank you

Fan Li

Mime
View raw message