0
votes

I am running a flow in mule with 3 queues(rabbitmq). Here is my configuration xml

<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:amqp="http://www.mulesoft.org/schema/mule/amqp" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
    <amqp:connector name="AMQP_Connector1" validateConnections="true" fallbackAddresses="localhost:5672" doc:name="AMQP Connector1"/>
    <flow name="putToQueue1" doc:name="putToQueue1">
        <http:inbound-endpoint exchange-pattern="one-way" host="localhost" port="8081" path="message" doc:name="HTTP"/>
        <set-payload value="#[message.inboundProperties['msg']]" doc:name="Set Payload"/>        
            <processor-chain doc:name="Processor Chain">
                <amqp:outbound-endpoint queueName="test.queue1" responseTimeout="10000" doc:name="AMQP1" connector-ref="AMQP_Connector1"/>
                <custom-processor class="CustomProcessor" doc:name="Custom Processor"/>
                <amqp:outbound-endpoint queueName="test.queue2" responseTimeout="10000" doc:name="AMQP2" connector-ref="AMQP_Connector1"/>
                <custom-processor class="CustomProcessor" doc:name="Custom Processor"/>
                <amqp:outbound-endpoint queueName="test.queue3" responseTimeout="10000"  doc:name="AMQP3" connector-ref="AMQP_Connector1"/>
           </processor-chain>       
    </flow>
</mule>

Here is the CustomProcessor java class

import org.mule.api.MuleEvent;
import org.mule.api.MuleException;
import org.mule.api.processor.MessageProcessor;


public class CustomProcessor implements MessageProcessor {

    @Override
    public MuleEvent process(MuleEvent event) throws MuleException {
        String message = (event.getMessage().getPayload() +" "+ System.currentTimeMillis());
        event.getMessage().setPayload(message);
        return event;
    }

}

When I hit the url in the browser(using http endpoint), 1 message is delivered to queue3 via queue1 and queue2. First, the message is put at queue1 which transfers it to queue2 and then queue2 to queue3. After transferring the message to other queue, previous queue should not retain the message. But when I hit the url second time. I am getting the below exception

Caused by: java.lang.LinkageError: loader (instance of  org/mule/module/launcher/plugin/MulePluginsClassLoader): attempted  duplicate class definition for name: "org/mule/transport/amqp/AmqpMuleMessageFactory"
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    ..............
1
Some version-specific issues or configuration details, maybe? I could not reproduce this exception with Studio 3.5.0 on Centos 6.4, no Maven. - Anton Kupias

1 Answers

0
votes

What you trying to do is to recreate already existing queue. Think of it as if you have queue1 on the server and then you are trying to create this queue again. RabbitMQ doesn't know if this is a mistake or your explicitly want to do this. In the second case you need to pass passive flag when you creating a queue

take a look at here: https://www.rabbitmq.com/amqp-0-9-1-reference.html

bit passive

If set, the server will reply with Declare-Ok if the queue already exists with the same name, and raise an error if not. The client can use this to check whether a queue exists without modifying the server state. When set, all other method fields except name and no-wait are ignored. A declare with both passive and no-wait has no effect. Arguments are compared for semantic equivalence.