EvaluationContext Null With Spring Integration and Kafka - spring

I am attempting to define a simple message flow in Spring Integration that reads from one channel and then dumps the messages into a Kafka queue. To do this, I am using spring-integration-kafka. The problem is I get an EvaluationContext error I can't decipher.
Here is my configuration in XML:
<int:channel id="myStreamChannel"/>
<int:gateway id="myGateway" service-interface="com.myApp.MyGateway" >
<int:method name="process" request-channel="myStreamChannel"/>
</int:gateway>
<int:channel id="activityOutputChannel"/>
<int:transformer input-channel="myStreamChannel" output-channel="activityOutputChannel" ref="activityTransformer"/>
<int-kafka:outbound-channel-adapter id="kafkaOutboundChannelAdapter"
kafka-producer-context-ref="kafkaProducerContext"
auto-startup="false"
channel="activityOutputChannel"
topic="my-test"
message-key-expression="header.messageKey">
<int:poller fixed-delay="1000" time-unit="MILLISECONDS" receive-timeout="0" task-executor="taskExecutor"/>
</int-kafka:outbound-channel-adapter>
<task:executor id="taskExecutor"
pool-size="5-25"
queue-capacity="20"
keep-alive="120"/>
<int-kafka:producer-context id="kafkaProducerContext" producer-properties="producerProperties">
<int-kafka:producer-configurations>
<int-kafka:producer-configuration broker-list="kafkaserver.com:9092"
key-class-type="java.lang.String"
value-class-type="java.lang.String"
topic="my-test"
key-encoder="stringEncoder"
value-encoder="stringEncoder"
compression-codec="snappy"/>
</int-kafka:producer-configurations>
</int-kafka:producer-context>
When I run my application via Spring Boot, I get this exception:
Error creating bean with name 'org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
This is the offending line in the stack trace:
at org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler.onInit(KafkaProducerMessageHandler.java:68)
Here is what happens at Line 68:
Assert.notNull(this.evaluationContext);
So the EvaluationContext is null. I have no idea why.
By the way, when I replace the Kafka endpoint with a trivial stdout endpoint to print the message body, everything works fine.
Can you tell me what is wrong with my Kafka endpoint configuration that there is no EvaluationContext available?

Your issue belongs to the version mismatch hell.
The Spring Boot pulls that Spring Integration Core version, which doesn't support IntegrationEvaluationContextAware to populate the EvaluationContext in the KafkaProducerMessageHandler.
So, you should upgrade Spring Integration Kafka to most recent release: https://github.com/spring-projects/spring-integration-kafka/releases

Related

SpringXD and Integration: Bridge, polleable &subscribable channels

I'm reading the Spring Integration documentation to figure out how to implment a bridge with polleable and subscribable channels (which will be one of my SpringXD modules).
So the documentation related to the bridge says that basically, I should do something like:
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd">
<channel id="pollable" />
<bridge input-channel="pollable" output-channel="subscribable">
<poller max-messages-per-poll="10" fixed-rate="5000" />
</bridge>
<channel id="subscribable" />
Then I'm creating a SpringXD Stream like:
stream create source-customBridge-sink-testing --definition "kafka-source:kafka --zkconnect=localhost:2181 --topic=first-queue | custom-bridge | kafka-sink:kafka --topic=regular-queue" --deploy
But I'm getting:
2017-03-16T12:52:06-0300 1.3.0.RELEASE INFO DeploymentSupervisor-0 zk.ZKStreamDeploymentHandler - Deployment status for stream 'source-customBridge-sink-testing': DeploymentStatus{state=failed,error(s)=org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.sprin
gframework.integration.config.ConsumerEndpointFactoryBean#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: A poller should not be specified for endpoint 'org.springframework.integration.config.ConsumerEndpointFactoryBean#0', since 'pollable' is a Subscrib.
What am I missing?
The problem that you are missing that the pollable must be declared as :
<channel id="pollable">
<queue/>
</channel>

How to configure Jboss EAP7.0 WorkManager in Spring 4.2

I am trying to implement the jca based jms in spring with Jboss EAP 7.0 and below are my configuration.
<bean class="org.jboss.resource.adapter.jms.JmsResourceAdapter" id="jbossResourceAdapter"/>
<bean id="messageHubTaskExecuter" class="org.springframework.jca.work.WorkManagerTaskExecutor">
<property name="workManager" value="wm/default"/>
</bean>
<bean id="jbossResourceAdapterFactory" class="org.springframework.jca.support.ResourceAdapterFactoryBean">
<property name="resourceAdapter" ref="jbossResourceAdapter"/>
<property name="workManager" ref="messageHubTaskExecuter"/>
</bean>
I got the below exception
Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: wm/default -- service jboss.naming.context.java.wm.default
Caused by: javax.naming.NameNotFoundException: wm/default -- service jboss.naming.context.java.wm.default"}}
Please let me know how to get the work manager instance in spring 4.2 from Jboss EAP 7.0
Thanks much.

Error connecting ActiveMQ

I am working on ActiveMQ JMS Spring application. I am using ActiveMQ instance which is present in Cloud server and i trying to read message from queue. In a configuration file i have configured broker URL as
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<!-- brokerURL, You may have different IP or port -->
<constructor-arg index="0" value="tcp://ip address:8161" />
</bean>
but when i try to connect it gives me error
Caused by: org.apache.activemq.transport.InactivityIOException: Cannot send, channel has already failed: tcp://ip address:8161
at org.apache.activemq.transport.AbstractInactivityMonitor.doOnewaySend(AbstractInactivityMonitor.java:297)
at org.apache.activemq.transport.AbstractInactivityMonitor.oneway(AbstractInactivityMonitor.java:286)
at org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.java:85)
at org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:104)
at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)
at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81)
at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:86)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1409)
... 21 more
Can you please suggest me is am i missing something here?

Spring Batch Admin - how to get annotated beans to be recognized?

I am using the spring-batch-admin-sample application as the starting point for a project. I have a working spring-batch job that is built with annotations that I am integrating with the console.
When I jar it up and add it to my console project, the annotations are not honored. In order to test this, I have gone as far as to add the tag to the job, so an attempt to build the job bean means that the annotation-config tag has been seen and processed.
Can anyone see what I am missing?
Thanks in advance.
Environment
OS: Windows 7
Java: jdk 1.8.0_25
Spring Batch Admin Sample version: 1.3.1
Spring version: 3.2.13 * stock 3.2.9 has a bug that causes this symptom
Spring-batch version: 3.0.2
Pivotal tc version: 3.0 Developer Edition
IDE: STS 3.6.3
Log Snip:
14:27:13.667 [localhost-startStop-1] WARN ... Error creating bean with name 'step0002-fetch':
**Cannot resolve reference to bean 'sourceSelectionReader'**
while setting bean property 'itemReader'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'sourceSelectionReader' is defined
Job Bean Definition
<context:annotation-config/>
<bean class="org.springframework.batch.core.scope.StepScope" />
<batch:job id="my-job">
<batch:step id="step0002-fetch" >
<batch:tasklet transaction-manager="transactionManager" start-limit="100" >
<batch:chunk reader="sourceSelectionReader" writer="selectedDataWriter" commit-interval="1" />
</batch:tasklet>
<batch:next on="*" to="step0003-archive-purge"/>
</batch:step>
</batch:job
Class definition:
#Component("sourceSelectionReader")
#Scope(value="step", proxyMode = ScopedProxyMode.INTERFACES)
public class SourceSelectionReaderImpl
implements ItemReader<Object>,SourceSelectionReader, ApplicationContextAware {
...
}
The tag
<context:annotation-config/>
should have been
<context:component-scan/>
... looking for a rock to crawl under ...
See Difference between <context:annotation-config> vs <context:component-scan> for an explanation.

Apache CXF multiple bus definitios

I am trying to using CXF with multiples endpoints and 2 bus definitions, here is my configurations:
<jaxws:endpoint id="csSegSEndPoint"
implementor="#csSegServices"
address="/ESTSServices"
bus="busEST">
</jaxws:endpoint>
<cxf:bus name="busEST">
<cxf:inInterceptors>
<ref bean="logInbound"/>
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="logOutbound"/>
</cxf:outInterceptors>
</cxf:bus>
The thing is that when I start the application I get:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'csSegSEndPoint': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
I did some search and I cannot get what I am doing wrong. Could you please help me?
NOTE: I am using CXF 2.2.10.
salu2..
masch...
This never really worked until CXF 2.4.x sometime. Definitely upgrade. 2.2.10 is ancient, buggy, unsupported and has a BUNCH of security issues.

Resources