You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Fan Li <fa...@gmail.com> on 2006/03/08 21:19:47 UTC
code change request
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
Fwd: code change request
Posted by Fan Li <fa...@gmail.com>.
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 <fa...@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
Fwd: code change request
Posted by Fan Li <fa...@gmail.com>.
that was not easy to read, try this again
---------- Forwarded message ----------
From: Fan Li <fa...@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