I tried servicemix-jms.
StandardConsumerProcessor does not use javax.jms.MessageListener and it
can be used in web container or ejb container.
But other servicemix-jms components for example
MultiplexingConsumerProcessor gets the same
javax.jms.IllegalStateException...
I needed to improve jmsEndpoint, StandardConsumerProcessor component and
I wrote my own JmsEndpoint and ConsumerProcessor component but the
code became very complicated, and to make it work was very complicated
compared to a custom lightweight component.
I think it would be nice if we could write marshaller for JBI components
like it is written for lightweight components.
If marshaller can be written for JBI components it may keep us from
writing custom endpoints or JBI components to make small improvements at
the available JBI components.
Maybe, because of my lack of servicemix knowledge, I could not find a
good solution with servicemix -jms.
As a result, I solved my problem by using
org.springframework.jms.listener.DefaultMessageListenerContainer and
service-mix together.
It may help others too and all the comments about the solution is
appreciated.
<sm:activationSpec componentName="MyLogListener"
service="foo:MyLogListener">
<sm:component>
<ref bean="myMessageListener" />
</sm:component>
</sm:activationSpec>
<bean id="myMessageListener"
class="com.test.utils.jms.MyMessageListener ">
<property name="marshaler">
<bean class="com.test.utils.jms.MyJmsMarshaller"
/>
</property>
</bean>
<!-- Container definirion must be later than component
definition -->
<bean id="MonitoringLogListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
>
<property name="concurrentConsumers" value="5"/>
<property name="connectionFactory"
ref="jmsConnectionFactory" />
<property name="destinationName"
value="${Payment.Queue.Log}" />
<property name="messageListener" ref="myMessageListener"
/>
</bean>
public class MyMessageListener extends ComponentSupport implements
MessageExchangeListener, MessageListener {
protected final transient Log log =
LogFactory.getLog(getClass());
private JmsMarshaler marshaler = new JmsMarshaler();
public JmsMarshaler getMarshaler() {
return marshaler;
}
public void setMarshaler(JmsMarshaler marshaler) {
this.marshaler = marshaler;
}
public void onMessage(Message jmsMessage) {
if (log.isTraceEnabled()) {
log.trace("Received: " + jmsMessage);
}
try {
InOnly messageExchange =
getDeliveryChannel().createExchangeFactory().createInOnlyExchange();
NormalizedMessage inMessage =
messageExchange.createMessage();
try {
marshaler.toNMS(inMessage, jmsMessage);
messageExchange.setInMessage(inMessage);
getDeliveryChannel().send(messageExchange);
}
catch (JMSException e) {
messageExchange.setError(e);
messageExchange.setStatus(ExchangeStatus.ERROR);
}
}
catch (JBIException e) {
throw new RuntimeJBIException(e);
}
}
public void onMessageExchange(MessageExchange exchange) throws
MessagingException {
// Do nothing as we only send in-only
// but this ensure that messages are not queued in the
DeliveryChannel
}
}
-----Original Message-----
From: Guillaume Nodet [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 19, 2006 4:06 PM
To: [email protected]
Subject: Re: "javax.jms.IllegalStateException: Method setMessageListener
not permitted"
You may want to try with servicemix-jms
with a processorName="standard" attribute.
See http://servicemix.goopen.org/site/servicemix-jms.html
Else, you could raise a JIRA and attach a patch :)
On 10/19/06, Alper Sogukpinar (Garanti Teknoloji)
<[EMAIL PROTECTED]> wrote:
>
>
>
> I run service-mix in web container and I use
> org.apache.servicemix.components.jms.JmsReceiverComponent in WAS 6.1
> but I get
> "javax.jms.IllegalStateException: Method setMessageListener not
> permitted"
> Error. When I searched it I found that "javax.jms.MessageConsumer
> method setMessageListener()" (which is used in JmsReceiverComponent)
> and some other methods may only be used by an application running in a
> client container -- in other words, they may never be called in the
> Web or EJB container:
> In below documents MDB usage is suggested.Is there a solution using
> Servixemix components?
> Any suggestions or workaround about the problem is appriciated.
>
> http://www-128.ibm.com/developerworks/java/library/j-getmess/
> http://www-304.ibm.com/jct09002c/isv/tech/faq/individual.jsp?oid=1:804
> 81
>
> This message and attachments are confidential and intended solely for
> the individual(s) stated in this message. If you received this message
> although you are not the addressee, you are responsible to keep the
> message confidential. The sender has no responsibility for the
> accuracy or correctness of the information in the message and its
> attachments. Our company shall have no liability for any changes or
late receiving, loss of integrity and confidentiality, viruses and any
damages caused in anyway to your computer system.
>
>
> Bu mesaj ve ekleri, mesajda gonderildigi belirtilen kisi/kisilere
> ozeldir ve gizlidir. Bu mesajin muhatabi olmamaniza ragmen tarafiniza
> ulasmis olmasi halinde mesaj iceriginin gizliligi ve bu gizlilik
> yukumlulugune uyulmasi zorunlulugu tarafiniz icin de soz konusudur.
> Mesaj ve eklerinde yer alan bilgilerin dogrulugu ve guncelligi
> konusunda gonderenin ya da sirketimizin herhangi bir sorumlulugu
> bulunmamaktadir. Sirketimiz mesajin ve bilgilerinin size degisiklige
ugrayarak veya gec ulasmasindan, butunlugunun ve gizliliginin
korunamamasindan, virus icermesinden ve bilgisayar sisteminize
verebilecegi herhangi bir zarardan sorumlu tutulamaz.
>
--
Cheers,
Guillaume Nodet
This message and attachments are confidential and intended solely for the
individual(s) stated in this
message. If you received this message although you are not the addressee, you
are responsible to keep the
message confidential. The sender has no responsibility for the accuracy or
correctness of the
information in the message and its attachments. Our company shall have no
liability for any changes
or late receiving, loss of integrity and confidentiality, viruses and any
damages caused in
anyway to your computer system.
Bu mesaj ve ekleri, mesajda gonderildigi belirtilen kisi/kisilere ozeldir ve
gizlidir. Bu mesajin muhatabi
olmamaniza ragmen tarafiniza ulasmis olmasi halinde mesaj iceriginin gizliligi
ve bu gizlilik yukumlulugune
uyulmasi zorunlulugu tarafiniz icin de soz konusudur. Mesaj ve eklerinde yer
alan bilgilerin dogrulugu ve
guncelligi konusunda gonderenin ya da sirketimizin herhangi bir sorumlulugu
bulunmamaktadir. Sirketimiz
mesajin ve bilgilerinin size degisiklige ugrayarak veya gec ulasmasindan,
butunlugunun ve gizliliginin
korunamamasindan, virus icermesinden ve bilgisayar sisteminize verebilecegi
herhangi bir zarardan
sorumlu tutulamaz.