没有合适的资源?快使用搜索试试~ 我知道了~
JBI开发指南(Servicemix开发指南)
4星 · 超过85%的资源 需积分: 12 58 下载量 171 浏览量
2013-09-10
11:23:10
上传
评论 1
收藏 432KB PDF 举报
温馨提示
试读
90页
servicemix的开发文档很少,本人好费劲才淘到一本JBI的开发指南,书写的很不错,如果学习完全书肯定能达到入门级水平,嘿嘿,学人已学过大半,收益非浅。
资源推荐
资源详情
资源评论
JBI User's Guide
Apache ServiceMix
Version 4.5.0
1
1. Introduction to JBI
1.1. What is JBI?
TODO: Describe what the JBI specification is all about
1.2. Message Exchange Patterns
TODO: Describe the four standard JBI MEPs
1.3. JBI API
TODO: Describe the standard JBI API (MessageExchange, NormalizedMessage, ...)
Apache ServiceMix 4.5.0
2
2. JBI Components
2.1. servicemix-bean
Overview
The ServiceMix Bean component provides integration with beans (POJOs) with the JBI bus to make it
easy to use POJOs to process JBI message exchanges. Like in an Message Driven Bean in J2EE a POJO
will receive a message from the NMR and process it in any way it likes. Unlike in a JMS component
where the coding is already done the Bean component gives the developer the freedom to create any
type of message handling but it must be hand coded all the way.
Namespace and xbean.xml
The namespace URI for the servicemix-bean JBI component is http://servicemix.apache.org/
bean/1.0. This is an example of an xbean.xml file with a namespace definition with prefix bean.
<beans<beans xmlns:bean="http://servicemix.apache.org/bean/1.0">>
<bean:endpoint<bean:endpoint service="test:service" endpoint="endpoint" bean="#listenerBean"/>/>
<bean<bean id="listenerBean" class="org.apache.servicemix.bean.beans.ListenerBean"/>/>
</beans></beans></beans></beans>
Endpoint types
The servicemix-bean component only defines one endpoint, called bean:endpoint. It can be used
to receive and send message exchanges from/to the NMR.
Endpoint bean:endpoint
There are two ways to configure the bean endpoint. The first is using the fully qualified name of the
class and the second is by passing to the endpoint a reference to an existing bean.
Using a Java class
When definining a bean:endpoint specifying a Java class name, a new instance of this class will be
created for handling a single message exchange.
<beans<beans xmlns:bean="http://servicemix.apache.org/bean/1.0"
xmlns:my="urn:org:servicmix:docs:examples">>
<bean:endpoint<bean:endpoint service="my:service" endpoint="endpoint"
class="org.apache.servicemix.docs.bean.MyHandlerBean"/>/>
</beans></beans>
Using a spring bean
Alternative, a reference to an existing bean can be passed to the bean endpoint.
Apache ServiceMix 4.5.0
3
<beans<beans xmlns:bean="http://servicemix.apache.org/bean/1.0">>
<bean:endpoint<bean:endpoint service="test:service" endpoint="endpoint" bean="#listenerBean"/>/>
<bean<bean id="listenerBean" class="org.apache.servicemix.bean.beans.ListenerBean"/>/>
</beans></beans>
Attention: The Bean Endpoint schema allows to set a Bean or a Bean Name. The Bean will create a
single instance of the POJO per endpoint whereas the Bean Name will create an instance per request
(message exchange).
Endpoint properties
Property Name Type Description
applicationContext
org.springframework.context.ApplicationContext
Set the Spring
ApplicationContext
where the bean can
be found. Defaults
to the context
defined in
xbean.xml
bean
java.lang.Object
Set the bean to be
used for handling
exchanges
beanClassName
java.lang.String
Set the bean class
name to be used
for handling
exchanges. A new
instance will be
created on the fly
for every exchange.
beanInfo
org.apache.servicemix.bean.support.BeanInfo
Set a custom bean
info object to
define the bean to
be used for
handling
exchanges
beanName
java.lang.String
Set the name of the
bean in the
application context
to be used for
handling
exchanges
beanType
java.lang.Class
Set the bean class
to be used for
handling
exchanges. A new
instance will be
created on the fly
for every exchange.
component
org.apache.servicemix.bean.BeanComponent
correlationExpression
org.apache.servicemix.expression.Expression
Set a custom
expression to use
for correlating
exchanges into a
single request
handled by the
same bean
instance. The
default expression
uses a correlation
Apache ServiceMix 4.5.0
4
ID set on the
exchange
properties.
endpoint
java.lang.String
<p> Get the
endpoint
implementation.
</p>
interfaceName
javax.xml.namespace.QName
<p> Get the
qualified name of
the endpoint
interface. </p>
methodInvocationStrategy
org.apache.servicemix.bean.support.MethodInvocationStrategy
Set a custom
invocation strategy
to define how the
bean is being
invoked. The
default
implementation
takes some
additional
parameter
annotations into
account.
service
javax.xml.namespace.QName
<p> Get the
service qualified
name of the
endpoint. </p>
serviceEndpoint
javax.jbi.servicedesc.ServiceEndpoint
MessageExchangeListener
The first kind of POJOs you can deploy implement the MessageExchagneListener interface. In such
a case, servicemix-bean acts as a replacement of the lightweight container component. This level
offers the most control on the exchange received and sent. This is usually used with the injected
DeliveryChannel to send back the exchanges, or if the POJOs needs to act as a consumer (i.e.
creating and sending exchanges to other services).
These POJOs are low-level POJOs: you need to understand the JBI Api and Message Exchange
Patterns to correctly handle incoming exchanges.
Note that at this point (v 3.1), there is no base class that you can inherit to speed you in this process
of implementing a POJO to handle JBI exchanges, but hopefully it will come in the future.
Examples
This example on the right shows the most simple bean. When it receives an exchange, it will print it
to the console and set the status to DONE before sending the exchange back. This bean can not
handle InOut exchanges, as it does not set any response (an exception would be thrown in such a
case).
Apache ServiceMix 4.5.0
5
剩余89页未读,继续阅读
美国队长
- 粉丝: 2
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页