[ 
https://issues.apache.org/jira/browse/ARTEMIS-2608?focusedWorklogId=408618&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-408618
 ]

ASF GitHub Bot logged work on ARTEMIS-2608:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Mar/20 09:36
            Start Date: 24/Mar/20 09:36
    Worklog Time Spent: 10m 
      Work Description: fvaleri commented on pull request #2954: ARTEMIS-2608 
Fix ClassCastException on binary properties conversion
URL: https://github.com/apache/activemq-artemis/pull/2954#discussion_r397015637
 
 

 ##########
 File path: 
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPResenderToOpenwireTest.java
 ##########
 @@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.crossprotocol;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.qpid.jms.JmsConnectionFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AMQPResenderToOpenwireTest extends ActiveMQTestBase {
+
+   private static final String OPENWIRE_URL = "tcp://localhost:61616";
+   private static final String AMQP_URL = "amqp://localhost:61616";
+
+   private ActiveMQServer server;
+   private ActiveMQConnectionFactory factory;
+   private JmsConnectionFactory qpidFactory;
+
+   private String queueZeroName = "queue.zero";
+   private String queueOneName = "queue.one";
+
+   @Override
+   @Before
+   public void setUp() throws Exception {
+      super.setUp();
+      server = createServer(true, true);
+
+      factory = new ActiveMQConnectionFactory(OPENWIRE_URL);
+      qpidFactory = new JmsConnectionFactory(AMQP_URL);
+
+      Configuration serverConfig = server.getConfiguration();
+      serverConfig.getAddressesSettings().put("#", new 
AddressSettings().setAutoCreateQueues(true)
+            .setAutoCreateAddresses(true).setDeadLetterAddress(new 
SimpleString("ActiveMQ.DLQ")));
+      serverConfig.setSecurityEnabled(false);
+      server.start();
+
+      SimpleString coreQueueZero = new SimpleString(queueZeroName);
+      server.createQueue(coreQueueZero, RoutingType.ANYCAST, coreQueueZero, 
null, false, false);
+
+      SimpleString coreQueueOne = new SimpleString(queueOneName);
+      server.createQueue(coreQueueOne, RoutingType.ANYCAST, coreQueueOne, 
null, false, false);
+   }
+
+   @Override
+   @After
+   public void tearDown() throws Exception {
+      if (server != null) {
+         server.stop();
+         server = null;
+      }
+   }
+
+   @Test(timeout = 60_000)
+   public void openwireInternalBinaryPropertiesShouldBeResentAsByteArrays() 
throws Exception {
+      final List<Throwable> errors = new LinkedList<>();
+      final ExecutorService executor = Executors.newFixedThreadPool(2);
+      final CountDownLatch resenderReady = new CountDownLatch(1);
+
+      // AMQP resender
+      executor.execute(new Runnable() {
+         @Override
+         public void run() {
+            try {
+
+               Connection connection = qpidFactory.createConnection();
+               Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+
+               Queue queueZero = session.createQueue(queueZeroName);
+               Queue queueOne = session.createQueue(queueOneName);
+
+               MessageConsumer consumer = session.createConsumer(queueZero);
+               connection.start();
+               resenderReady.countDown();
+               Message message = consumer.receive();
+               assertNotNull(message);
+
+               MessageProducer producer = session.createProducer(queueOne);
+               producer.send(message);
+
+               connection.close();
+
+            } catch (Exception e) {
+               errors.add(e);
+            }
+         }
+      });
+
+      // OpenWire client
+      executor.execute(new Runnable() {
+         @Override
+         public void run() {
+            try {
+
+               Connection connection = factory.createConnection();
+               Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+
+               Queue queueZero = session.createQueue(queueZeroName);
+               Queue queueOne = session.createQueue(queueOneName);
+
+               MessageProducer producer = session.createProducer(queueZero);
+               Message testMessage = session.createTextMessage("test");
+               resenderReady.await(20, TimeUnit.SECONDS);
 
 Review comment:
   yes, I think it can be avoided, let me do some tests before removing it
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 408618)
    Time Spent: 5h 20m  (was: 5h 10m)

> ClassCastException when consuming a message using OpenWire
> ----------------------------------------------------------
>
>                 Key: ARTEMIS-2608
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2608
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: AMQP, OpenWire
>    Affects Versions: 2.11.0
>            Reporter: Federico Valeri
>            Priority: Major
>          Time Spent: 5h 20m
>  Remaining Estimate: 0h
>
> This issue seems to be related to the conversion of binary properties.
>  Quick workaround: clear message properties in the AMQP producer.
> Reproducer (attached):
>  1. Send a message to the broker using OpenWire client
>  2. Consume that message using AMQP client
>  3. Send that message back to the broker using AMQP client
> Result: message could not be consumed by the OpenWire consumer.
> {code:java}
> 2020-01-23 12:52:44,095 WARN [org.apache.activemq.artemis.core.server] Error 
> during message dispatch: java.lang.ClassCastException: 
> org.apache.activemq.artemis.api.core.SimpleString cannot be cast to [B
>  at 
> org.apache.activemq.artemis.core.protocol.openwire.OpenWireMessageConverter.toAMQMessage(OpenWireMessageConverter.java:629)
>  [artemis-openwire-protocol-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.core.protocol.openwire.OpenWireMessageConverter.createMessageDispatch(OpenWireMessageConverter.java:501)
>  [artemis-openwire-protocol-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConsumer.handleDeliver(AMQConsumer.java:258)
>  [artemis-openwire-protocol-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession.sendMessage(AMQSession.java:312)
>  [artemis-openwire-protocol-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl.deliverStandardMessage(ServerConsumerImpl.java:1161)
>  [artemis-server-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl.proceedDeliver(ServerConsumerImpl.java:504)
>  [artemis-server-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.core.server.impl.QueueImpl.proceedDeliver(QueueImpl.java:3510)
>  [artemis-server-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.core.server.impl.QueueImpl.deliver(QueueImpl.java:2856)
>  [artemis-server-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.core.server.impl.QueueImpl.access$2300(QueueImpl.java:122)
>  [artemis-server-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.core.server.impl.QueueImpl$DeliverRunner.run(QueueImpl.java:3848)
>  [artemis-server-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:42)
>  [artemis-commons-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:31)
>  [artemis-commons-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> org.apache.activemq.artemis.utils.actors.ProcessorBase.executePendingTasks(ProcessorBase.java:66)
>  [artemis-commons-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  [rt.jar:1.8.0_232]
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  [rt.jar:1.8.0_232]
>  at 
> org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
>  [artemis-commons-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to