You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by razu programista <ra...@gmail.com> on 2008/11/26 14:37:59 UTC
How to set JMSExpiration property?
Hello everybody,
I have a problem with removing unused messages from ActiveMQ queue. The
problem is that when I peek messages which resides in ActiveMQ queue in
jconsole, I see that their JMSExpiration property is set to 0. But I wrote
my own jms provider marshaler which sets this property to my custom value.
The code looks like:
// marshaler
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.NormalizedMessage;
import javax.jms.Message;
import org.apache.servicemix.jms.endpoints.DefaultProviderMarshaler;
public class MyMarshaler extends DefaultProviderMarshaler {
public void populateMessage(Message message, MessageExchange exchange,
NormalizedMessage normalizedMessage) throws Exception {
super.populateMessage(message, exchange, normalizedMessage);
message.setJMSExpiration(10000);
}
}
// jms xbean.xml config
<jms:provider service="test:clientProviderService"
endpoint="clientProviderEndpoint"
destinationName="outClientQueue"
marshaler="#myMarshaler"
connectionFactory="#connectionFactory"/>
<bean id="myMarshaler" class="com.test.MyMarshaler" />
Despite of setting JMSExpiration property in custom marshaler, JMSExpiration
property is 0. Have you any idea what is wrong?
Re: How to set JMSExpiration property?
Posted by zimny rado <ra...@gmail.com>.
Ok, I solved the problem, in <jms:provider /> endpoint there must be defined
timeToLive property in conjunction with explicitQosEnabled="true" property.
2008/11/27 zminy rado <ra...@gmail.com>
>
> Hello again, after few test, i noticed that I was using wrong method in
> DefaultProviderMarshaler, now I have problem with overriding JMSExpiration
> property, I've tried timeToLive and receiveTimeout properties in
> <jms:provider /> endpoint, but it seems that properties sets some exchange
> behaviour instead of message. This is the code for my custom marshaler, and
> configuration of <jms:provider /> endpoint, in this marshaler I'm setting
> JMSExpiration property and JMSCorrelationID property and only JMSExpiration
> property is overriden to 0.
>
> This is view of message in activemq queue:
> http://img213.imageshack.us/img213/1121/jconsolekx9.jpg
>
> import javax.jbi.messaging.NormalizedMessage;
> import javax.jms.JMSException;
> import javax.jms.Message;
>
> import org.apache.log4j.Logger;
> import org.apache.servicemix.jms.endpoints.DefaultProviderMarshaler;
>
> public class MyMarshaler extends DefaultProviderMarshaler {
>
> private static final Logger LOG = Logger.getLogger(MyMarshaler.class);
>
> protected void copyPropertiesFromNM(NormalizedMessage
> normalizedMessage, Message message) throws JMSException {
> message.setJMSExpiration(10000);
> message.setJMSCorrelationID("custom_corrid");
> super.copyPropertiesFromNM(normalizedMessage, message);
> if (message.getJMSExpiration() != 10000) {
> LOG.error("===================== this is stupid
> ============================");
> }
> }
> }
>
>
> <jms:provider service="test:clientProviderService"
> endpoint="clientProviderEndpoint"
> destinationName="outClientQueue"
> connectionFactory="#xaConnectionFactory"
> marshaler="#myMarshaler" />
>
> <bean id="myMarshaler" class="com.test.MyMarshaler" />
>
> <bean id="transactionManager"
> class="org.jencks.factory.TransactionManagerFactoryBean" />
>
> <amqpool:xa-pool id="xaConnectionFactory"
> brokerURL="tcp://localhost:61616?jms.useAsyncSend=true"
> transactionManager="#transactionManager" maxConnections="100" />
>
> Do you supose, what overriding JMSExpiration property?
>
>
>
>
> 2008/11/27 zminy rado <ra...@gmail.com>
>
> Hello,
>>
>> I've tried property timeToLive in <jms:provider /> endpoint, but this is
>> not setting the JMSExpiration property. But I noticed that <jms:provider />
>> do not use my custom marshaler. Do you know when <jms:provider /> endpoint
>> ignore custom marshalers?
>>
>> 2008/11/26 Gert Vanthienen <ge...@skynet.be>
>>
>> L.S.,
>>>
>>> The JMSExpiration you set in the Marshaler is probably being overridden
>>> by the TimeToLive value specified on the Producer.
>>> Could you try adding the timeToLive="10000" attribute to your
>>> <jms:provider/> endpoint to see if that yields the desired result?
>>>
>>> Regards,
>>>
>>> Gert
>>>
>>>
>>>
>>> razu programista wrote:
>>>
>>>> Hello everybody,
>>>> I have a problem with removing unused messages from ActiveMQ queue. The
>>>> problem is that when I peek messages which resides in ActiveMQ queue in
>>>> jconsole, I see that their JMSExpiration property is set to 0. But I
>>>> wrote
>>>> my own jms provider marshaler which sets this property to my custom
>>>> value.
>>>> The code looks like:
>>>>
>>>> // marshaler
>>>>
>>>> import javax.jbi.messaging.MessageExchange;
>>>> import javax.jbi.messaging.NormalizedMessage;
>>>> import javax.jms.Message;
>>>>
>>>> import org.apache.servicemix.jms.endpoints.DefaultProviderMarshaler;
>>>>
>>>> public class MyMarshaler extends DefaultProviderMarshaler {
>>>>
>>>> public void populateMessage(Message message, MessageExchange
>>>> exchange,
>>>> NormalizedMessage normalizedMessage) throws Exception {
>>>> super.populateMessage(message, exchange, normalizedMessage);
>>>> message.setJMSExpiration(10000);
>>>> }
>>>> }
>>>>
>>>> // jms xbean.xml config
>>>>
>>>> <jms:provider service="test:clientProviderService"
>>>> endpoint="clientProviderEndpoint"
>>>> destinationName="outClientQueue"
>>>> marshaler="#myMarshaler"
>>>> connectionFactory="#connectionFactory"/>
>>>>
>>>> <bean id="myMarshaler" class="com.test.MyMarshaler" />
>>>>
>>>>
>>>>
>>>> Despite of setting JMSExpiration property in custom marshaler,
>>>> JMSExpiration
>>>> property is 0. Have you any idea what is wrong?
>>>>
>>>>
>>>>
>>>
>>>
>>
>
Re: How to set JMSExpiration property?
Posted by zminy rado <ra...@gmail.com>.
Hello again, after few test, i noticed that I was using wrong method in
DefaultProviderMarshaler, now I have problem with overriding JMSExpiration
property, I've tried timeToLive and receiveTimeout properties in
<jms:provider /> endpoint, but it seems that properties sets some exchange
behaviour instead of message. This is the code for my custom marshaler, and
configuration of <jms:provider /> endpoint, in this marshaler I'm setting
JMSExpiration property and JMSCorrelationID property and only JMSExpiration
property is overriden to 0.
This is view of message in activemq queue:
http://img213.imageshack.us/img213/1121/jconsolekx9.jpg
import javax.jbi.messaging.NormalizedMessage;
import javax.jms.JMSException;
import javax.jms.Message;
import org.apache.log4j.Logger;
import org.apache.servicemix.jms.endpoints.DefaultProviderMarshaler;
public class MyMarshaler extends DefaultProviderMarshaler {
private static final Logger LOG = Logger.getLogger(MyMarshaler.class);
protected void copyPropertiesFromNM(NormalizedMessage normalizedMessage,
Message message) throws JMSException {
message.setJMSExpiration(10000);
message.setJMSCorrelationID("custom_corrid");
super.copyPropertiesFromNM(normalizedMessage, message);
if (message.getJMSExpiration() != 10000) {
LOG.error("===================== this is stupid
============================");
}
}
}
<jms:provider service="test:clientProviderService"
endpoint="clientProviderEndpoint"
destinationName="outClientQueue"
connectionFactory="#xaConnectionFactory"
marshaler="#myMarshaler" />
<bean id="myMarshaler" class="com.test.MyMarshaler" />
<bean id="transactionManager"
class="org.jencks.factory.TransactionManagerFactoryBean" />
<amqpool:xa-pool id="xaConnectionFactory"
brokerURL="tcp://localhost:61616?jms.useAsyncSend=true"
transactionManager="#transactionManager" maxConnections="100" />
Do you supose, what overriding JMSExpiration property?
2008/11/27 zminy rado <ra...@gmail.com>
> Hello,
>
> I've tried property timeToLive in <jms:provider /> endpoint, but this is
> not setting the JMSExpiration property. But I noticed that <jms:provider />
> do not use my custom marshaler. Do you know when <jms:provider /> endpoint
> ignore custom marshalers?
>
> 2008/11/26 Gert Vanthienen <ge...@skynet.be>
>
> L.S.,
>>
>> The JMSExpiration you set in the Marshaler is probably being overridden by
>> the TimeToLive value specified on the Producer.
>> Could you try adding the timeToLive="10000" attribute to your
>> <jms:provider/> endpoint to see if that yields the desired result?
>>
>> Regards,
>>
>> Gert
>>
>>
>>
>> razu programista wrote:
>>
>>> Hello everybody,
>>> I have a problem with removing unused messages from ActiveMQ queue. The
>>> problem is that when I peek messages which resides in ActiveMQ queue in
>>> jconsole, I see that their JMSExpiration property is set to 0. But I
>>> wrote
>>> my own jms provider marshaler which sets this property to my custom
>>> value.
>>> The code looks like:
>>>
>>> // marshaler
>>>
>>> import javax.jbi.messaging.MessageExchange;
>>> import javax.jbi.messaging.NormalizedMessage;
>>> import javax.jms.Message;
>>>
>>> import org.apache.servicemix.jms.endpoints.DefaultProviderMarshaler;
>>>
>>> public class MyMarshaler extends DefaultProviderMarshaler {
>>>
>>> public void populateMessage(Message message, MessageExchange exchange,
>>> NormalizedMessage normalizedMessage) throws Exception {
>>> super.populateMessage(message, exchange, normalizedMessage);
>>> message.setJMSExpiration(10000);
>>> }
>>> }
>>>
>>> // jms xbean.xml config
>>>
>>> <jms:provider service="test:clientProviderService"
>>> endpoint="clientProviderEndpoint"
>>> destinationName="outClientQueue"
>>> marshaler="#myMarshaler"
>>> connectionFactory="#connectionFactory"/>
>>>
>>> <bean id="myMarshaler" class="com.test.MyMarshaler" />
>>>
>>>
>>>
>>> Despite of setting JMSExpiration property in custom marshaler,
>>> JMSExpiration
>>> property is 0. Have you any idea what is wrong?
>>>
>>>
>>>
>>
>>
>
Re: How to set JMSExpiration property?
Posted by zminy rado <ra...@gmail.com>.
Hello,
I've tried property timeToLive in <jms:provider /> endpoint, but this is not
setting the JMSExpiration property. But I noticed that <jms:provider /> do
not use my custom marshaler. Do you know when <jms:provider /> endpoint
ignore custom marshalers?
2008/11/26 Gert Vanthienen <ge...@skynet.be>
> L.S.,
>
> The JMSExpiration you set in the Marshaler is probably being overridden by
> the TimeToLive value specified on the Producer.
> Could you try adding the timeToLive="10000" attribute to your
> <jms:provider/> endpoint to see if that yields the desired result?
>
> Regards,
>
> Gert
>
>
>
> razu programista wrote:
>
>> Hello everybody,
>> I have a problem with removing unused messages from ActiveMQ queue. The
>> problem is that when I peek messages which resides in ActiveMQ queue in
>> jconsole, I see that their JMSExpiration property is set to 0. But I wrote
>> my own jms provider marshaler which sets this property to my custom value.
>> The code looks like:
>>
>> // marshaler
>>
>> import javax.jbi.messaging.MessageExchange;
>> import javax.jbi.messaging.NormalizedMessage;
>> import javax.jms.Message;
>>
>> import org.apache.servicemix.jms.endpoints.DefaultProviderMarshaler;
>>
>> public class MyMarshaler extends DefaultProviderMarshaler {
>>
>> public void populateMessage(Message message, MessageExchange exchange,
>> NormalizedMessage normalizedMessage) throws Exception {
>> super.populateMessage(message, exchange, normalizedMessage);
>> message.setJMSExpiration(10000);
>> }
>> }
>>
>> // jms xbean.xml config
>>
>> <jms:provider service="test:clientProviderService"
>> endpoint="clientProviderEndpoint"
>> destinationName="outClientQueue"
>> marshaler="#myMarshaler"
>> connectionFactory="#connectionFactory"/>
>>
>> <bean id="myMarshaler" class="com.test.MyMarshaler" />
>>
>>
>>
>> Despite of setting JMSExpiration property in custom marshaler,
>> JMSExpiration
>> property is 0. Have you any idea what is wrong?
>>
>>
>>
>
>
Re: How to set JMSExpiration property?
Posted by Gert Vanthienen <ge...@skynet.be>.
L.S.,
The JMSExpiration you set in the Marshaler is probably being overridden
by the TimeToLive value specified on the Producer.
Could you try adding the timeToLive="10000" attribute to your
<jms:provider/> endpoint to see if that yields the desired result?
Regards,
Gert
razu programista wrote:
> Hello everybody,
> I have a problem with removing unused messages from ActiveMQ queue. The
> problem is that when I peek messages which resides in ActiveMQ queue in
> jconsole, I see that their JMSExpiration property is set to 0. But I wrote
> my own jms provider marshaler which sets this property to my custom value.
> The code looks like:
>
> // marshaler
>
> import javax.jbi.messaging.MessageExchange;
> import javax.jbi.messaging.NormalizedMessage;
> import javax.jms.Message;
>
> import org.apache.servicemix.jms.endpoints.DefaultProviderMarshaler;
>
> public class MyMarshaler extends DefaultProviderMarshaler {
>
> public void populateMessage(Message message, MessageExchange exchange,
> NormalizedMessage normalizedMessage) throws Exception {
> super.populateMessage(message, exchange, normalizedMessage);
> message.setJMSExpiration(10000);
> }
> }
>
> // jms xbean.xml config
>
> <jms:provider service="test:clientProviderService"
> endpoint="clientProviderEndpoint"
> destinationName="outClientQueue"
> marshaler="#myMarshaler"
> connectionFactory="#connectionFactory"/>
>
> <bean id="myMarshaler" class="com.test.MyMarshaler" />
>
>
>
> Despite of setting JMSExpiration property in custom marshaler, JMSExpiration
> property is 0. Have you any idea what is wrong?
>
>