Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.camel.component.jms;

import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;

import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
Expand Down Expand Up @@ -57,7 +58,7 @@ public void testSendEmptyMessage() throws Exception {
sendExchange("");
sendExchange(null);

resultEndpoint.assertIsSatisfied();
MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
}

protected void assertSendAndReceiveBody(Object expectedBody) throws InterruptedException {
Expand All @@ -66,7 +67,7 @@ protected void assertSendAndReceiveBody(Object expectedBody) throws InterruptedE

sendExchange(expectedBody);

resultEndpoint.assertIsSatisfied();
MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
}

protected void sendExchange(final Object expectedBody) {
Expand All @@ -85,8 +86,8 @@ protected RouteBuilder createRouteBuilder() {

return new RouteBuilder() {
public void configure() {
from(startEndpointUri).to(endEndpointUri);
from(endEndpointUri).to("mock:result");
from(startEndpointUri).routeId("jmsRoute1").to(endEndpointUri);
from(endEndpointUri).routeId("jmsRoute2").to("mock:result");
}
};
}
Expand All @@ -103,5 +104,8 @@ void setUpRequirements() {
consumer = camelContextExtension.getConsumerTemplate();

resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class);

// Wait for the JMS consumer routes to be fully subscribed to the broker
JmsTestHelper.waitForJmsConsumerRoutes(context, "jmsRoute1", "jmsRoute2");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.concurrent.TimeUnit;

import org.apache.camel.component.jms.JmsTestHelper;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Tags;
Expand Down Expand Up @@ -45,6 +46,9 @@ protected AbstractApplicationContext createApplicationContext() {

@Test
public void testFailover() throws Exception {
// Wait for the JMS consumer routes to be fully subscribed to the broker
JmsTestHelper.waitForJmsConsumerRoutes(context, "fooConsumerRoute", "barConsumerRoute");

getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:bar").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.concurrent.TimeUnit;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsTestHelper;
import org.apache.camel.component.jms.integration.spring.AbstractSpringJMSITSupport;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.MethodOrderer;
Expand All @@ -44,10 +45,13 @@ protected ClassPathXmlApplicationContext createApplicationContext() {
@Order(1)
@Test
public void testRouteId() throws Exception {
// Wait for the JMS consumer route to be fully subscribed to the broker
JmsTestHelper.waitForJmsConsumerRoutes(context, "myCoolRoute");

getMockEndpoint("mock:error").expectedMessageCount(0);
getMockEndpoint("mock:result").expectedMessageCount(1);

template.sendBody("activemq:queue:RouteIdTransactedTest", "Hello World");
template.sendBody("activemq:queue:RouteIdTransactedIT", "Hello World");

MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);

Expand All @@ -58,10 +62,13 @@ public void testRouteId() throws Exception {
@Order(2)
@Test
public void testRouteIdFailed() throws Exception {
// Wait for the JMS consumer route to be fully subscribed to the broker
JmsTestHelper.waitForJmsConsumerRoutes(context, "myCoolRoute");

getMockEndpoint("mock:error").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedMessageCount(0);

template.sendBody("activemq:queue:RouteIdTransactedTest", "Kaboom");
template.sendBody("activemq:queue:RouteIdTransactedIT", "Kaboom");

MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);

Expand All @@ -74,7 +81,7 @@ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
public void configure() {
from("activemq:queue:RouteIdTransactedTest?transacted=true").id("myCoolRoute")
from("activemq:queue:RouteIdTransactedIT?transacted=true").id("myCoolRoute")
.onException(IllegalArgumentException.class).handled(true).to("log:bar").to("mock:error").end()
.transacted()
.choice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="agent" disabled="true"/>

<route>
<route id="loadBalanceRoute">
<from uri="direct:start"/>
<loadBalance>
<failoverLoadBalancer/>
<to uri="jms:queue:foo?transferException=true"/>
<to uri="jms:queue:bar?transferException=true"/>
<to uri="jms:queue:JmsSpringLoadBalanceFailOver.foo?transferException=true"/>
<to uri="jms:queue:JmsSpringLoadBalanceFailOver.bar?transferException=true"/>
</loadBalance>
<to uri="mock:result"/>
</route>

<route>
<from uri="jms:queue:foo?transferException=true"/>
<route id="fooConsumerRoute">
<from uri="jms:queue:JmsSpringLoadBalanceFailOver.foo?transferException=true"/>
<to uri="mock:foo"/>
<throwException ref="damn"/>
</route>

<route>
<from uri="jms:queue:bar?transferException=true"/>
<route id="barConsumerRoute">
<from uri="jms:queue:JmsSpringLoadBalanceFailOver.bar?transferException=true"/>
<to uri="mock:bar"/>
<transform><simple>Bye World</simple></transform>
</route>
Expand Down