[
https://issues.apache.org/jira/browse/CAMEL-16377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17304912#comment-17304912
]
Dmytro Chasovskyi edited comment on CAMEL-16377 at 3/19/21, 1:51 PM:
---------------------------------------------------------------------
[~davsclaus]
The code I am using to test the route:
SpringBoot app
{code:java}
@SpringBootApplication
@PropertySource("classpath:application-test.properties")
class TestApp {
public static void main(String[] args) {
SpringApplication.run(TestApp.class, args);
}
}
{code}
SpringRunner, invoking Spring Boot spp:
{code:java}
@RunWith(SpringRunner.class)
@TestPropertySource(locations = "application-test.properties")
@SpringBootTest(classes = TestApp.class, webEnvironment = DEFINED_PORT)
public class FunctionalTest {
@Autowired
private EventConsumeCreator eventConsumerCreator;
private List<Endpoint> consumers;
private static final MockComponent MOCK_COMPONENT = new MockComponent();
@Before
public void before() {
// Setting Wiremock and LogAsserts
consumers = eventConsumerCreator.getConsumers();
consumers.clear();
consumers.add(new MockEndpoint("direct:xyz", MOCK_COMPONENT));
}
@Test
public checkNumEvents() {
// Make requests to endpoints
// Verify logs
// Check wiremock asserts
assertThat(numEvents(consumers), is(1));
}
}
{code}
Utility class creating direct endpoints:
{code:java}
@Component
public class EventConsumerCreator {
private List<Endpoint> consumers = new LinkedList<>();
private CamelContext camelContext;
@Autowired
public EventConsumerCreator(CamelContext camelContext){
this.camelContext = camelContext;
}
public List<Endpoint> getConsumers() {
return consumers;
}
public Endpoint createConsumer(String identifier) {
Endpoint endpoint = createEndpoint(identifier);
consumers.add(endpoint);
return endpoint;
}
private Endpoint createEndpoint(String identifier) {
DirectComponent component = camelContext.getComponent("direct",
DirectComponent.class);
try{
return component.createEndpoint("direct://" + identifier);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
}
{code}
{{In the simplified version of the endpoint itself, I removed properties
setting and logging:}}
{code:java}
from("direct:abc")
.route("abc-123")
.streamCaching()
.recipientList(exchangeProperty("xyz")).parallelProcessing() // returns
"[direct:xyz]"
.log("Success"){code}
was (Author: chameleontartu):
[~davsclaus]
The code I am using to test the route:
SpringBoot app
@SpringBootApplication
@PropertySource("classpath:application-test.properties")
class TestApp \{
public static void main(String[] args) {
SpringApplication.run(TestApp.class, args);
}
}
SpringRunner, invoking Spring Boot spp:
{{}}
@RunWith(SpringRunner.class)
@TestPropertySource(locations = "application-test.properties")
@SpringBootTest(classes = TestApp.class, webEnvironment = DEFINED_PORT)
public class FunctionalTest \{
@Autowired
private EventConsumeCreator eventConsumerCreator;
private List<Endpoint> consumers;
private static final MockComponent MOCK_COMPONENT = new MockComponent();
@Before
public void before() {
// Setting Wiremock and LogAsserts
consumers = eventConsumerCreator.getConsumers();
consumers.clear();
consumers.add(new MockEndpoint("direct:xyz", MOCK_COMPONENT));
}
@Test
public checkNumEvents() \{
// Make requests to endpoints
// Verify logs
// Check wiremock asserts
assertThat(numEvents(consumers), is(1));
}
}
Utility class creating direct endpoints:
@Component
public class EventConsumerCreator \{
private List<Endpoint> consumers = new LinkedList<>();
private CamelContext camelContext;
@Autowired
public EventConsumerCreator(CamelContext camelContext) {
this.camelContext = camelContext;
}
public List<Endpoint> getConsumers() \{
return consumers;
}
public Endpoint createConsumer(String identifier) \{
Endpoint endpoint = createEndpoint(identifier);
consumers.add(endpoint);
return endpoint;
}
private Endpoint createEndpoint(String identifier) \{
DirectComponent component = camelContext.getComponent("direct",
DirectComponent.class);
try {
return component.createEndpoint("direct://" + identifier);
} catch (Exception e) \{
throw new RuntimeException(e);
}
}
}
{{The simplified version of endpoint itself, I removed properties setting and
logging:}}
{code:java}
from("direct:abc")
.route("abc-123")
.streamCaching()
.recipientList(exchangeProperty("xyz")).parallelProcessing() // returns
"[direct:xyz]"
.log("Success"){code}
> camel-core - Recipient List EIP - Failed to create Producer for endpoint -
> NPE in ServicePool
> ---------------------------------------------------------------------------------------------
>
> Key: CAMEL-16377
> URL: https://issues.apache.org/jira/browse/CAMEL-16377
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 3.7.3
> Reporter: Dmytro Chasovskyi
> Priority: Minor
> Fix For: 3.7.4, 3.10.0
>
>
> Hi, this is more like a question.
> I am switching from the 2.24 version to 3.7.3, and I am getting an error in
> the .recepietnList. [StackOverflow
> question|https://stackoverflow.com/questions/66692194/how-to-solve-org-apache-camel-failedtocreateproducerexception-caughtexceptionmes]
> The error itself:
> CaughtExceptionType: org.apache.camel.FailedToCreateProducerException
> CaughtExceptionMessage: Failed to create Producer for endpoint: direct:xyz.
> Reason: java.lang.NullPointerException StackTrace:
> org.apache.camel.FailedToCreateProducerException: Failed to create Producer
> for endpoint: direct:xyz Reason:
> java.lang.NullPointerExceptionCaughtExceptionType:
> org.apache.camel.FailedToCreateProducerException CaughtExceptionMessage:
> Failed to create Producer for endpoint: direct:xyz. Reason:
> java.lang.NullPointerException StackTrace:
> org.apache.camel.FailedToCreateProducerException: Failed to create Producer
> for endpoint: direct:xyz. Reason: java.lang.NullPointerException at
> org.apache.camel.support.cache.DefaultProducerCache.acquireProducer(DefaultProducerCache.java:154)
> at
> org.apache.camel.processor.RecipientListProcessor.createProcessorExchangePairs(RecipientListProcessor.java:219)
> at
> org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:276)
> at
> org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:222)
> at org.apache.camel.processor.RecipientList.process(RecipientList.java:185)
> at org.apache.camel.processor.Pipeline$PipelineTask.run(Pipeline.java:90) at
> org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148)
> at
> org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:60)
> at org.apache.camel.processor.Pipeline.process(Pipeline.java:147) at
> org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:312)
> at
> org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:274)
> at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:187)
> at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:130) at
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
> at
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
> at java.base/java.lang.Thread.run(Thread.java:832)Caused by:
> java.lang.NullPointerException at
> org.apache.camel.support.cache.ServicePool$SinglePool.acquire(ServicePool.java:210)
> at
> org.apache.camel.support.cache.ServicePool$SinglePool.acquire(ServicePool.java:193)
> at org.apache.camel.support.cache.ServicePool.acquire(ServicePool.java:109)
> at
> org.apache.camel.support.cache.DefaultProducerCache.acquireProducer(DefaultProducerCache.java:125)
> ... 15 more
> It looks like the behavior changed between versions. Is there a way how I can
> address it? I walked through the migration guide, search StackOverflow, but
> there is no progress. Any idea?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)