The class org.apache.activemq.artemis.jms.client.ActiveMQMessage implements
javax.jms.Message but not javax.jms.TextMessage. You'd need a
org.apache.activemq.artemis.jms.client.ActiveMQTextMessage to be able to
cast to javax.jms.TextMessage.

Given that you're sending a javax.jms.TextMessage and *not* receiving a
javax.jms.TextMessage back I'd guess there's another message on the queue.
I'd probably need a reproducer to investigate further.


Justin

On Thu, Mar 25, 2021 at 10:08 AM <tobias.w...@t-systems.com> wrote:

> Ok I see.
> What is wrong here in the jms client code?
>
>                 Connection connection =
> this.connectionFactory.createConnection();
>                 Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>         Destination smtpQueue =
> session.createQueue(MailServerEmbeddedActiveMQServer.ACTIVE_MQ_SMTP_QUEUE);
>                 MessageProducer producer =
> session.createProducer(smtpQueue);
>                 MessageConsumer consumer =
> session.createConsumer(smtpQueue);
>                 connection.start();
>                 TextMessage message = session.createTextMessage("This is
> an order");
>                 producer.send(message);
>                 TextMessage receivedMessage = (TextMessage)
> consumer.receive(); --> HERE COMES THE EXCEPTION!!!!
>                 System.out.println("Got order: " +
> receivedMessage.getText());
>
> java.lang.ClassCastException: class
> org.apache.activemq.artemis.jms.client.ActiveMQMessage cannot be cast to
> class javax.jms.TextMessage
> (org.apache.activemq.artemis.jms.client.ActiveMQMessage and
> javax.jms.TextMessage are in unnamed module of loader 'app')
>         at com.tsystems.gematik.kim.mailserver.mq
> .MailServerActiveMQJmsClient.sendJMSMessageToSmtpQueue(MailServerActiveMQJmsClient.java:47)
>         at com.tsystems.gematik.kim.mailserver.mq
> .MailServerActiveMQClientTest.sendAndReceiveByteBufMessage(MailServerActiveMQClientTest.java:28)
>         at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>         at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>         at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>         at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>         at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>         at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>         at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>         at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>         at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>         at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>         at
> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>         at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>         at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>         at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>         at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
>         at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
>
>
> -----Ursprüngliche Nachricht-----
> Von: Justin Bertram <jbert...@apache.org>
> Gesendet: Donnerstag, 25. März 2021 15:44
> An: users@activemq.apache.org
> Betreff: Re: EmbeddedJMS
>
> Yes. EmbeddedActiveMQ supports JMS. However, it will probably be helpful
> to read the short chapter on how JMS is mapped to core [1].
>
> The EmbeddedJMS class was removed because it was ultimately redundant.
> There's really nothing special about JMS support from the broker's point
> of view. The heaving lifting is done by the JMS & JNDI client
> implementations.
>
>
> Justin
>
> [1]
>
> http://activemq.apache.org/components/artemis/documentation/latest/jms-core-mapping.html
>
> On Thu, Mar 25, 2021 at 8:50 AM <tobias.w...@t-systems.com> wrote:
>
> > Hi Domenico,
> >
> > does "EmbeddedActiveMQ" support JMS?
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Domenico Francesco Bruscino <bruscin...@gmail.com>
> > Gesendet: Donnerstag, 25. März 2021 14:46
> > An: users@activemq.apache.org
> > Betreff: Re: EmbeddedJMS
> >
> > Hi Tobias,
> >
> > EmbeddedJMS was deprecated in favor of
> > org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ,
> > according the java doc[1]. You can find further detail in the ActiveMQ
> > Artemis documentation[2].
> >
> > [1]
> >
> > https://activemq.apache.org/components/artemis/documentation/javadocs/
> > javadoc-latest/org/apache/activemq/artemis/jms/server/embedded/Embedde
> > dJMS.html
> > [2]
> >
> > https://activemq.apache.org/components/artemis/documentation/latest/em
> > bedding-activemq.html
> >
> > Regards,
> > Domenico
> >
> >
> > On Thu, 25 Mar 2021 at 14:28, <tobias.w...@t-systems.com> wrote:
> >
> > > I saw that EmbeddedJMS is deprecated.
> > > Is there already a successor class which can be used instead of?
> > > I'm currently using this code to start activemq artemis server and I
> > > want now to implement/start the jms server too.
> > >
> > >        public void startServer() throws Exception {
> > >              this.configuration = new ConfigurationImpl();
> > >              this.configuration.addAcceptorConfiguration("in-vm",
> > > ACTIVE_MQ_EMBEDDED_SERVER_URL);
> > >              this.configuration.setPersistenceEnabled(true);
> > >              this.configuration.setSecurityEnabled(false);
> > >              this.configuration.addQueueConfiguration(new
> > > QueueConfiguration(ACTIVE_MQ_SMTP_QUEUE));
> > >
> > >              JMSConfiguration jmsConfig = new
> > > JMSConfigurationImpl();
> > >
> > >              TransportConfiguration connectorConfig = new
> > > TransportConfiguration(InVMAcceptorFactory.class.getName());
> > >              ConnectionFactoryConfiguration cfConfig = new
> > > ConnectionFactoryConfigurationImpl();
> > >        jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);
> > >
> > >              JMSQueueConfiguration queueConfig = new
> > > JMSQueueConfigurationImpl();
> > >               jmsConfig.getQueueConfigurations().add(queueConfig);
> > >
> > >              this.server = new ActiveMQServerImpl(this.configuration);
> > >              this.server.start();
> > >        }
> > >
> > >        public void stopServer() throws Exception {
> > >              if (this.server != null)
> > >                     this.server.stop();
> > >        }
> > >
> >
>

Reply via email to