进程原语和线程原语是啥意思_转换中介原语

本文详细介绍了如何将WebSphere ESB的StockQuote示例资源转换为IBM Integration Bus资源,涉及了Message Logger原语、转换工具待办事项、数据库日志记录等方面,展示了转换过程中的关键步骤和注意事项。
摘要由CSDN通过智能技术生成

进程原语和线程原语是啥意思

本文向您展示如何将WebSphere ESB StockQuote样本(IBM Integration Designer随附)中的资源转换为IBM Integration Bus资源。 StockQuote示例使用带有SOAP / JMS Web服务绑定的导出。 由StockQuote中介流记录输入的JMS消息,然后该中介流使用来自输入的客户ID值,并基于文件中的查找确定客户的订阅级别为“常规”还是“高级”。 使用XML映射将输入消息本身转换为不同的消息格式,可以使用带有绑定到两个后端服务之一的SOAP / HTTP Web服务的导入来发送输入消息。 来自Premium客户的消息被路由到RealtimeService ,而来自普通客户的消息被路由到DelayedService 。 无论调用哪种服务,从标注返回的响应消息都将转换为响应消息,然后StockQuote将其返回给JMS客户端。 下面的组装图中显示了WebSphere ESB组件之间的关系:

WebSphere ESB StockQuote示例的组装图
WebSphere ESB StockQuote示例的组装图

本文底部的“下载”部分提供了一个名为PI_WESB_StockQuote.zip项目交换文件。 它包含两个未转换的项目,如下表1所示:

PI_WESB_StockQuote.zip中用于转换的WebSphere ESB资源的描述
IID项目 项目类型 目的
资源资源 图书馆 该库包含业务对象定义,这些定义为与StockQuote和StockQuoteProvider中介流交换的消息建模。
股票报价 调解模块 此中介模块包含将转换为IBM Integration Bus资源的导出,导入和中介流组件。

本系列文章的第1部分讨论了如何运行IBM Integration Bus转换工具,因此此处将不详细介绍这些步骤。 启动IBM Integration Bus集成工具包,并从一个空的工作空间开始。 导入可下载的WebSphere ESB项目交换文件PI_WESB_StockQuote.zip并启动转换工具。 在默认项目位置WESB_Conversions创建一个命名转换会话。

接下来,遵循转换工具的五个步骤,以生成IBM Integration Bus资源。 如果在转换过程中选择默认设置,则该工具将生成消息流和相关资源,在该工具运行后会留下一些手动任务。 本文的其余部分详细描述了这些待办事项。 该讨论将显示WebSphere ESB和IBM Integration Bus在方法上的一些概念上的差异,并且在您转换自己的WebSphere ESB资源时应该会有所帮助。 在转换工具的最后一步中,审阅页上列出了15个待办事项,乍一看似乎要做很多,其中一些任务可以一起解决。

转换工具待办事项

消息记录器原语

StockQuote中介流的“请求”部分中的第一个原语是名为Log的消息记录器原语。 消息记录器中介原语用于在消息通过中介流时将其记录在关系数据库中。 IBM Integration Bus提供了几个可以将数据插入到关系数据库中的节点。 “计算”和“数据库”节点使用与数据库的ODBC通信来执行此操作,而“ JavaCompute”和“映射”节点使用与数据库的JDBC通信来执行此操作。

一项待办事项说明,缺省情况下,转换工具会将在WebSphere ESB中介流中找到的Message Logger原语转换为IBM Integration Bus占位符子流。 然后,由用户决定将此子流中的Passthrough节点替换为他们想要使用的特定IBM Integration Bus消息流节点。 那些熟悉Message Logger原语的人通常喜欢继续使用JDBC,这将IBM Integration Bus的选择范围缩小到在JavaCompute节点中编写代码,或使用映射以图形方式完成任务。 本文演示了一种图形解决方案,如图2所示:

表示WebSphere ESB Message Logger原语的替换节点的日志子流
表示WebSphere ESB Message Logger原语xxx的替换节点的日志子流

插入数据的主要工作是由“映射”节点完成的。 IBM Integration Bus映射对他们期望接收的输入数据进行建模。 为了使此解决方案无论传入数据的格式如何都适用,该映射被设计为在BLOB消息域中接收数据。 该映射将BLOB数据转换为文本,该文本可插入定义为CLOB(字符大对象)的数据库列中。 通过使用DB2命令行处理器或DB2控制中心从数据库中进行选择,将列定义为CLOB数据类型使其易于阅读。 映射之前的名为RCD的Reset Content Descriptor节点的目的是将入站消息更改为BLOB消息域。 这使得解决方案可以重用,而与到达Log子流输入的消息域无关。 例如,它可以是JMS消息,DFDL消息或XMLNSC消息。 在RCD节点之前的Flow Order节点的目的是确保在将原始输入消息发送到子流的out终端之前,尝试将子流的分支插入数据库。 此设计还确保可以将原始消息在其原始消息域中发送到子流的输出。 如果数据库插入发生异常,则TryCatch节点将捕获问题并将异常路由到子流的Failure终端。

运行转换工具后,用户可以手动添加此子流,但是转换工具还提供了扩展机制,该机制允许在转换过程中自动创建所需的节点或节点集,以替换所有调解原语中的所有示例。发生特定类型的 这是在转换工具的第三步中配置的,如下图3所示:

为中介原语添加自定义转换器类
图03

以下说明通过使用上面讨论的子流解决方案替换MessageLogger的示例,演示了如何配置扩展中介原始转换器。 本文在Java项目WESB_ConversionExtensions中的MessageLoggerConverterClass.java提供了创建子流解决方案的转换器类。 该项目位于随附的名为PI_ConversionExtension.zip项目交换文件中。 继续之前,将此项目交换文件导入到您的工作区。

  1. 默认情况下,MessageLogger原语由名为Placeholder converter的Converter类转换为Subflow占位符。 单击Converter class列中的Placeholder converter,如上面的图3所示,以启动Select Converter Class对话框。
  2. Converter Java class字段旁边,单击“选择”按钮。
  3. 在出现的“ Open Type对话框中,选择MessageLoggerConverterClass ,然后单击“确定”按钮。
  4. 您将返回上一个对话框,并且现在已填充Converter Java class字段。 单击确定按钮。
  5. 除了现在已将MessageLogger原语的Converter类列条目设置为使用提供的扩展名之外,您将返回到原始的转换工具。

像以前一样,完成转换工具的其余步骤。 在第四步中,当您单击“ Start Conversion按钮时,将警告您,首次运行该工具时创建的项目将被覆盖。 很好,因此只需在对话框上单击“确定”即可。

重新运行该工具后,您应该发现“待办事项”任务列表中不再包含警告您有关MessageLogger原语的条目,并且剩余的“待办事项”任务数应为14。

失败原语

待办事项列表中的两个任务说明了转换工具如何不具有内置功能来转换位于WebSphere ESB中介流中的Fail原语的实例。 缺省情况下,转换工具将用包含IBM Integration Bus Passthrough消息流节点的子流替换此中介原语的示例。 IBM Integration Bus中最接近的等效节点是Throw节点。 Throw节点用于在流的当前分支上生成(抛出)异常。 然后,异常将由最近的TryCatch节点或具有Catch终端的最近的先前节点(例如SOAPInput节点)捕获并处理。 IBM Integration Bus会将异常信息插入系统日志。 用Throw节点替换代替原始Fail原语生成的两个占位符子流。 完成此操作后,返回“待办事项”任务列表,并将与“失败”原语相关的两个任务标记为已完成。 现在,剩余的待办任务列表条目数为12。

XSL Transformation原语查找图

StockQuote中介流包含一个名为Lookup的XSL Transformation原语。 该原语使用映射通过查找转换将值分配到SMO上下文中。 Lookup转换从入站消息中获取CustomerId值,并将其用作在包含逗号分隔值的预定义文件内执行查找的键。 该文件包含有关所讨论的customerID是归类为具有高级还是常规订阅级别的规范 。 高级客户享有特权,因此可以致电更快的实时服务。 普通客户必须以较慢的速度致电延迟服务。 清单1中显示了Lookup转换访问的CSV文件的示例:

查找文件CustomerType.csv的内容
CustomerA,premium CustomerB,premium CustomerC,premium CustomerD,regular CustomerE,premium CustomerF,regular CustomerG,premium CustomerH,regular

不幸的是,IBM Integration Bus映射节点使用的映射没有与WebSphere ESB查找转换直接等效的映射。 出于这个原因,在生成的IBM Integration Bus映射中,通过一个Task将Lookup转换替换为Conversion工具,如图4所示:

从IBM Integration Bus映射Lookup_req_1中摘录,其中显示了一个代替WebSphere ESB Lookup Transform的任务
图04

IBM Integration Bus映射可以使用数据库表中的SELECT来实现这种功能需求。 IBM Integration Bus信息中心记录了在IBM Integration Bus映射中使用数据库的信息,但是在这里,我们将考虑IBM Integration Bus中的另一种替代方法,该替代方法继续使用文件进行查找。 FileRead节点可用于此目的。 您可以使用FileRead节点从消息流的中间读取一条记录或文件的全部内容,从而允许您基于文件中的查找来路由或丰富通过该流的消息。 删除转换工具生成的名为Lookup的Mapping节点,并将FileRead节点作为替换节点拖放到StockQuote_MediationFlow_getQuote_request.subflow占据的位置。 将FileRead节点加入到子流的其余部分:

  • 将Log子流的Output端子连接到FileRead节点的In端子
  • 将FileRead节点的Out端子连接到Filter节点的In端子
  • 将FileRead节点的No match端子连接到Filter节点的In端子

配置FileRead节点的“基本”选项卡的属性。 将输入目录设置为C:\Resources并将File name or pattern属性设置为CustomerType.csv 。 接下来,切换到FileRead节点属性的“结果”选项卡。 此选项卡上的属性说明应如何从CSV文件中提取所需的数据。 IBM Integration Bus将使用DFDL消息模型来解析CSV文件。 名为库CSVModel提供用于此目的,其被命名为附带的项目交换文件中PI_CSVModel.zip 。 继续之前,将此项目交换文件导入到您的工作区中。 右键单击IIB_StockQuote项目,然后选择“ Manage Library References ,然后将引用添加到CSVModel库。

FileRead节点还将使用XML模式描述LocalEnvironment树中的字段,这些字段将用于承载有关特定请求消息的发送者有权获得的订阅级别的信息。 在配置FileRead节点之前,我们需要稍微更改此模式(这是源自WebSphere ESB的转换资源之一)。 IIB_Resources project的更改会将全局元素定义添加到位于IIB_Resources project的命名空间包http://Resourse的Subscription模式中。 打开SubscriptionInformation.xsd并进行以下两个小更改。 进行了描述的更改之后,结果清单如下清单2所示:

  • 为targetNamespace添加名称空间前缀声明。
  • 添加一个名为SubscriptionInformation的全局元素,并使complexType(最初也称为SubscriptionInformation )在新的全局元素内成为匿名定义
进行必要的更改后列出SubscriptionInformation.xsd
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://Resourse" xmlns:sub="http://Resourse" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="SubscriptionInformation"> <xsd:complexType> <xsd:sequence> <xsd:element minOccurs="0" name="subscriptionLevel" type="xsd:string"> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>

保存架构,然后返回到FileRead节点的“结果属性”选项卡。 Result data location属性指定应从CSV文件中获取哪个字段。 用于此字段的XPath表达式导航到逻辑树结构中文件CSV数据解析到的所需位置。 Output data location属性指定将从CSV文件获取的值放置在逻辑消息树结构中的位置,该逻辑消息树结构将从文件读取节点传递出去。 要编辑这两个属性,请单击Edit ,然后使用XPath Expression builder ,如图5所示:

使用XPath Expression Builder设置结果数据位置
图05

“ XPath表达式”构建器对话框的目的是通知IBM Integration Bus如何为逻辑树的可变部分建模。 通过单击添加数据类型链接,然后选择相关的XML模式元素来完成此操作。 这两个字段的最终值应为:

  • 结果数据位置: $ResultRoot/DFDL/CustomerType/record/field2
  • 输出数据位置: $OutputLocalEnvironment/Variables/sub:SubscriptionInformation/subscriptionLevel

我们一直在编辑的LocalEnvironment树是逻辑消息树的暂存区,该逻辑区在内存中在IBM Integration Bus消息流的节点之间传递。 它在概念上与WebSphere ESB使用的SMO树的关联部分非常相似。

在FileRead节点的“结果”选项卡上设置的最终属性称为“记录选择”表达式。 此处定义的表达式告诉FileRead节点如何决定应使用CSV文件中的哪个记录。 这是基于使用customerID字段的值作为执行查找的键:

记录选择表达式:
$InputRoot/XMLNSC/tns:getQuote/request/customerID = $ResultRoot/DFDL/CustomerType/record/field1

“输入消息解析”选项卡指定FileRead节点应如何尝试解析文件中的数据。 如前所述,将DFDL解析器用于此任务。 设置属性:

消息域: DFDL
讯息: {}:CustomerType

IBM Integration Bus提供了一个向导来帮助您生成DFDL消息模型,该模型可用于解析许多不同种类的非XML数据,例如固定长度消息,带标签的定界格式,当然还有许多复杂的行业标准格式。 本文提供了DFDL模型,但是如果您对它的创建方式感兴趣,则可以在IBM Integration Bus信息中心中阅读有关此内容的更多信息。 配置FileRead节点后,返回“待办事项”任务列表,并将与“查找”原语有关的任务标记为已完成:完成此操作后,待办事项任务列表条目的剩余数量为11。

消息过滤器原语

转换工具在结果的IBM Integration Bus消息流中用Route节点替换Message Filter原语的实例。 找到“路由”节点(名为Filter )并检查其“基本”属性。 过滤器模式是指WebSphere ESB(SMO)树的上下文部分。 您将需要更改表中两个条目的过滤器模式,以引用IBM Integration Bus逻辑树的“本地环境”部分中的subscriptionLevel元素。 在“过滤器”表中依次选择每一行,然后单击“编辑”按钮并按如下所示设置值,然后保存子流:

名为Filter的Route节点的属性
过滤模式 路由输出端子
$ LocalEnvironment / Variables / sub:SubscriptionInformation / subscriptionLevel ='premium' 即时的
$ LocalEnvironment / Variables / sub:SubscriptionInformation / subscriptionLevel ='默认' 延迟时间

消息元素设置器原语

转换工具在所得IBM Integration Bus消息流中用Java Compute节点替换了Message Element Setter基本实例。 有两种可供选择的API格式,可以与IBM Integration Bus中的Java Compute节点一起使用。 IBM Integration Bus Java集成API提供了在消息消息传递的逻辑树中导航的方法。 自多年前将Java Compute节点首次引入该产品以来,这种方法就一直可用。 第二种方法是将IBM Integration Bus逻辑树转换为XML DOM树,然后使用JAXB get和set方法(从XML模式生成)来更改树的结构和值。 转换工具生成的Java Compute节点配置为使用JAXB方法。 故意采取了这种设计决策,以便用户可以以任何顺序应用在原始消息元素设置器原语上配置的(可能有很多)设置器指令。 因为节点了解输出数据格式,所以将应用设置程序指令,并且将以更正的顺序生成输出消息的字段。 如果使用了其他形式的Java Compute节点,则将按语句的执行顺序生成字段。

转换工具为SetCustomerType原语创建一个Java Compute节点,但是开发人员有责任使用XML模式生成JAXB get和set方法,然后将代码手动添加到节点的Java模板中以执行设置。语句复制为注释。 以下说明介绍了如何执行此操作:

  1. 从“开始”菜单中,打开IBM Integration Console 9.0.0.0,并将目录更改为Java Integration Kit的bin文件夹,该文件夹包含在IBM Integration Bus Toolkit安装中。 如果您使用了缺省安装位置,则该位置将位于C:\Program Files (x86)\IBM\IntegrationToolkit90\jdk\bin
  2. XML模式StockQuoteRequest.xsd对进入和离开SetCustomerType节点的数据进行SetCustomerType 。 该节点的目的是在LocalEnvironment树中设置默认的subscriptionLevel,但消息本身保持不变。 为此,我们只需要从描述预订级别的模式中生成Java对象类即可:
    xjc.exe -d <workspace_location>\IIB_StockQuoteJava -p jaxb_classes <workspace_location>\IIB_Resources\SubscriptionInformation.xsd
  3. 返回IBM Integration Toolkit,切换到Java透视图并刷新IIB_StockQuoteJava项目,您现在应该看到刚刚生成的jaxb_classes软件包。
  4. IIB_StockQuoteJava项目中,打开StockQuote_MediationFlow_getQuote_request_SetCustomerType.java ,它将在默认程序包中找到。 查看代码模板,您会发现转换工具添加了注释,描述了所需的set语句:
    // SET /context/correlation/subscriptionLevel to "regular"

    用清单3中的以下代码替换整个文件的内容:
StockQuote_MediationFlow_getQuote_request_SetCustomerType.java的Java代码
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import org.w3c.dom.Document; import com.ibm.broker.javacompute.MbJavaComputeNode; import com.ibm.broker.plugin.MbException; import com.ibm.broker.plugin.MbMessage; import com.ibm.broker.plugin.MbMessageAssembly; import com.ibm.broker.plugin.MbOutputTerminal; import com.ibm.broker.plugin.MbUserException; import com.ibm.broker.plugin.MbXMLNSC; import jaxb_classes.SubscriptionInformation; public class StockQuote_MediationFlow_getQuote_request_SetCustomerType extends MbJavaComputeNode { protected static JAXBContext jaxbContext = null; public void onInitialize() throws MbException { try { // Initialize the JAXB context with the Java object // classes that were generated by a JAXB binding compiler jaxbContext = JAXBContext.newInstance("jaxb_classes"); } catch (JAXBException e) { // This exception will cause the deploy of this Java compute node to fail // Typical cause is the JAXB package above is not available throw new MbUserException(this, "onInitialize()", "", "",e.toString(), null); } } public void evaluate(MbMessageAssembly assembly) throws MbException { MbOutputTerminal out = getOutputTerminal("out"); MbMessage localEnvironment = assembly.getLocalEnvironment(); try { // ---------------------------------------------------------- // Add user code below to build the new output data by updating // your Java objects or building new Java objects SubscriptionInformation outputLocalEnvironmentJavaObject = new SubscriptionInformation(); outputLocalEnvironmentJavaObject.setSubscriptionLevel("regular"); // End of user Java object processing // ---------------------------------------------------------- // Marshal the new or updated output Java object class into the Broker tree Document outDocumentLocalEnvironment = localEnvironment.createDOMDocument(MbXMLNSC.PARSER_NAME); jaxbContext.createMarshaller().marshal(outputLocalEnvironmentJavaObject, outDocumentLocalEnvironment); localEnvironment.getRootElement().getFirstElementByPath (MbXMLNSC.PARSER_NAME).setName("Variables"); // Propagate the output message assembly out.propagate(assembly); } catch (JAXBException e) { throw new MbUserException(this, "evaluate()", "", "", e.toString(), null); } } }

配置完此节点后,返回“待办事项”任务列表,并将与SetCustomerType原语有关的两个任务标记为已完成。 完成此操作后,剩余的待办任务列表条目数为9。

XSL Transformation原语TransformToRealtime映射

原始WebSphere ESB中介流中TransformToRealtime映射的目的是将StockQuote请求消息转换为Realtime服务的请求格式。 转换工具将自动将WebSphere ESB XML映射转换为IBM Integration Bus映射。 自动转换已成功完成,但是转换工具仍提供警告待办事项任务,以检查是否有任何错误或警告,但在此示例中没有任何错误或警告,因此您可以返回转换中存储的待办事项列表会话文件并将任务标记为完成。 完成此操作后,剩余的待办任务列表条目数为8。

XSL Transformation原语TransformToDelayed映射

StockQuote请求消息和“延迟服务”的请求格式之间的转换与我们刚刚处理的任务任务非常相似。 再次,对地图的快速比较显示自动转换工具已完美转换了映射,并且没有验证或警告消息。 返回存储在转换会话文件中的“待办事项”列表,并将任务标记为完成。 完成此操作后,剩余的待办任务列表条目数为7。

标注原始RealtimeService导入

转换工具会在生成的IBM Integration Bus消息流中用SOAPRequest节点自动替换WebSphere ESB Callout中介原语的实例。 在生成的名为StockQuote_MediationFlow_getQuote_Request.subflow子流中,找到名为RealtimeService的SOAPRequest节点,您将看到它的Basic属性已被自动配置。 转换工具会警告您,已在SOAPRequest节点的“ HTTP传输”属性选项卡上找到的端点地址已基于原始Callout原语分配了一个值。 该警告提醒您,如果调用的服务也是在WebSphere ESB中实现的,那么您很可能希望更改此URL。 本文提供了示例存根以模拟实时服务和延迟服务-作为IBM Integration Bus Services实现。 提供了这些存根服务,以便您可以在运行时成功测试转换后的消息流,而无需安装WAS或WebSphere ESB环境。 将Web服务URL属性中的端口号更改为7800。新的Web服务URL应为:

http://localhost:7800/StockQuoteProviderWeb/sca/RealtimeServicePortTypeExport1

返回到转换会话文件中存储的“待办事项”列表,并将有关终点的警告标记为已完成。 完成此操作后,剩余的待办任务列表条目数为6。

标注原语DelayedService导入

现在,我们将对与Delayed Service通信的SOAPRequest节点重复相同的任务。 在生成的名为StockQuote_MediationFlow_getQuote_Request.subflow子流中,找到名为DelayedService的SOAPRequest节点,然后在“ HTTP传输属性”选项卡上,更改Web服务URL。 因此端口号为7800。新的Web服务URL应为:

http://localhost:7800/StockQuoteProviderWeb/sca/DelayedServicePortTypeExport1

返回到转换会话文件中存储的“待办事项”列表,并将有关终点的警告标记为已完成。 完成此操作后,剩余的待办任务列表条目数为5。

XSL转换原语RealtimeToStockQuoteService映射

向实时服务或延迟服务发出请求后,该流程将使用其他映射将实时响应消息转换为StockQuote响应消息,并将延迟响应消息转换为Stockquote响应消息。 这些映射是自动转换的,但是我们现在将对其进行编辑,以便将本地环境树中的subscriptionLevel映射到qualityOfService元素,该元素可以在StockQuote响应消息中找到。 在映射中执行此操作将意味着我们可以完全从IBM Integration Bus消息流中完全除去SetQualityOfService原语(在映射节点之后)。

IIB_StockQuote项目中,打开RealtimeToStockQuoteService_res_1.map并单击源消息程序集,以便其属性出现在屏幕的底部。 在属性选项卡上,单击链接Headers and folders: Properties然后在弹出窗口中,通过勾选LocalEnvironment框并单击OK,将LocalEnvironment树添加到地图源。 展开现已添加到地图源的LocalEnvironment树,然后右键单击LocalEnvironment的Variables子树下的any元素。 选择Cast菜单操作,如下图6所示:

将定义的结构添加到LocalEnvironment的Variables部分
图06

从出现的“ Type Selection对话框中,选择SubscriptionInformation元素,然后单击“确定”。 将SubscriptionInformation元素添加到LocalEnvironment后,展开树,然后将subscriptionLevel元素拖放到getQuoteResponse目标消息中的qualityOfService元素。 单击刚刚创建的“移动”转换,然后查看其属性。 将数组索引(在下面的图7中用红色框突出显示)设置为值1。此步骤从Toolkit的“问题”视图中删除警告,该警告提醒您从数组映射时应设置基数。

在RealtimeToStockQuoteService地图上设置输入数组索引
图07

保存地图并返回存储在转换会话文件中的“待办事项”列表,并将有关地图的警告标记为已完成。 完成此操作后,剩余的待办任务列表条目数为4。

XSL转换原语DelayedToStockQuoteService映射

现在,对IIB_Resources项目中的DelayedToStockQuoteService映射进行相同的更改。 编辑自动转换的映射,以将subscriptionLevel从LocalEnvironment树移动到StockQuote响应消息中的qualityOfService元素。 就像我们上次执行的映射更改一样,请确保将“移动”变换上的数组索引设置为值1。此步骤从“工具箱”的“问题”视图中删除警告,提醒您在映射时应设置基数从数组。 保存地图并返回存储在转换会话文件中的“待办事项”列表,并将有关地图的警告标记为已完成。 完成此操作后,剩余的待办任务列表条目数为3。

消息元素设置器原语SetQualityOfService

名为SetQualityOfService的消息元素设置器原语被转换为JavaCompute节点。 但是,由于对映射DelayedToStockQuoteServiceRealtimeToStockQuoteService进行了较早的更改,当消息到达流中的这一点时,已经在准备StockQuote响应消息时对QualityOfService字段进行了分配。 因此,不再需要将此节点保留在消息流中,因此应将其删除。 将两个映射节点直接连接到输出节点( StockQuoteService_getQuote_InputResponse )。 还删除包含节点引用的java类的文件。 您将在项目IIB_StockQuoteJava找到名为StockQuote_MediationFlow_getQuote_request_SetQualityOfService.java文件。 返回到转换会话的“待办任务”列表,并将与SetQualityOfService节点有关的两个任务标记为已完成。 完成此操作后,应该只剩下一个需要执行操作的待办任务列表条目。

StockQuote导出JMS绑定

当转换工具生成IIB_StockQuote.msgflow ,将配置SOAPInput节点,以代替WebSphere ESB StockQuote服务上的Web服务(JMS)导出绑定。 该节点将接收到导致调用StockQuote服务的初始请求。 将该节点设置为通过JMS传输接收消息(在节点的“基本属性”选项卡上, Transport = JMS )。 检查“ JMS传输属性”选项卡,您将看到默认情况下该工具建议将WebSphere MQ用作JMS提供程序。 但是, SourceJNDI URL bindings locationConnection factory名称都需要配置。 添加了转换待办任务列表条目,以提醒用户在转换后应手动完成此操作。 我们现在将这样做。 如表3所示,在SOAPInput节点上设置值。这些JMS设置正确地对应于我们在测试流程之前将设置的JMS资源。

IIB_StockQuote.msgflow中SOAPInput节点的JMS属性
物业名称 适当的价值
资源 StockQuoteService
JNDI URL绑定位置 文件:/ C:/ JNDI-Directory
连接工厂名称 StockQuoteServiceQCF

配置完成后,JMS属性应如图8所示:

IIB_StockQuote.msgflow中SOAPInput节点的JMS属性
图08

保存消息流并返回到转换会话的“待办任务”列表,并将与JMS传输属性有关的最后一个任务标记为完成。 保存转换会话文件。 讨论了所有更改之后, StockQuote_MediationFlow_getQuote_request.subflow应该类似于图9:

最终StockQuote_MediationFlow_getQuote_request.subflow
图09

配置JMS绑定和队列定义

在测试转换后的资源之前,以下说明将帮助您设置JMS输入队列和输出队列。 本文包括一个名为Resources.zip的附件。 将文件的内容提取到目录C:\Resources (可以选择另一个目录,但是本文稍后的说明将假定此位置)。 该文件包含以下文件:

附件文件Resources.zip文件的内容
文档名称 目的
StockQuoteJMS.def 用于创建所需的JMS定义的配置文件。
股票报价WMQ.mqsc 用于创建所需的WMQ队列的配置文件。
CustomerType.csv 方案用来确定是调用实时服务还是延迟服务的查找文件。
JMSUtil.jar 提供了用于放置和获取JMS消息的测试实用程序。

现在检查是否有现有的JNDI绑定文件。 在Windows平台上,默认情况下,绑定文件位于目录C:\JNDI-Directory 。 如果此目录包含.bindings文件,则使用以下说明创建的定义将添加到该文件中。 或者,您可以删除现有的绑定文件,并且以下说明将从头开始创建一个新的绑定文件。 You can also configure WMQ to use an entirely new bindings file in a different location. If you wish to do this, then navigate to the WMQ installation subdirectory <WMQ_Installation_Directory>\java\bin . Add the following changes shown in Listing 4 to the JMSAdmin.config file. The PROVIDER_URL property points to the directory where you would like to generate the bindings:

Additions to JMSAdmin.config
INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory PROVIDER_URL=file:/C:/JNDI-Directory

Having configured the location for the bindings file, the following instructions describe how to generate the JMS definitions:

  1. Open an IBM Integration Bus Command Console window and change directory to the WMQ installation directory which is being used by the runtime broker that you intend to use for testing, and move to its subdirectory <WMQ_Installation_Directory>\java\bin . If you installed WMQ to the default location, then this will be C:\Program Files (x86)\IBM\WebSphere MQ\java\bin .
  2. Use the JMSAdmin command to set up the required Queue Connection Factory and queues:
    JMSAdmin.bat < C:\Resources\StockQuoteJMS.def

    The StockQuoteJMS.def file is provided with this article. It contains the following instructions (it is assumed that you will be using the default IBM Integration Bus configuration which involves a broker named IB9NODE , associated with a queue manager named IB9QMGR , which uses a listener on port 2414):

    DEF QCF(jms/StockQuoteServiceQCF) TRANSPORT(CLIENT) CHANNEL(SYSTEM.BKR.CONFIG)+ HOST(127.0.0.1) PORT(2414) QMGR(IB9QMGR) DEFINE Q(jms/StockQuoteService) QUEUE(STOCKQUOTE.IN) QMGR(IB9QMGR) DEFINE Q(jms/StockQuoteServiceResponse) QUEUE(STOCKQUOTE.OUT) QMGR(IB9QMGR) END
  3. Next, use the runmqsc command to set up the required WMQ queues (to which the JMS definitions above will bind). Do this from the same IBM Integration Bus Command Console window:
    runmqsc IB9QMGR < C:\Resources\StockQuoteWMQ.mqsc

    The StockQuoteWMQ.mqsc file is provided with this article. It contains the following instructions:
    def ql(STOCKQUOTE.IN) def ql(STOCKQUOTE.OUT)

Create the Log database

Earlier in the article we discussed the conversion extension point which replaces the WebSphere ESB Message Logger primitive with a Mapping node to insert data into a DB2 database. In order for this part of the flow to work, we need to create the database ready to receive the data to be logged:

  1. From the Windows start menu, launch the DB2 Command Line Processor window. Create the database using the following command:
    create db LOGDB
  2. In the same DB2 Command Line Processor window, connect to the database which you just created:
    connect to LOGDB
  3. Now create a table to store the data:
    CREATE TABLE DATAWAREHOUSE (MESSAGEDATA CLOB (1 M) NOT NULL, DBINSERTTIMESTAMP TIMESTAMP NOT NULL WITH DEFAULT CURRENT_TIMESTAMP)
  4. Exit the DB2 Command Line Processor:
    disconnect all quit exit

Create IBM Integration Bus JDBC configurable service

The runtime IBM Integration Bus Node where you intend to deploy your flow will need to be configured to be able to connect via JDBC to the Log database. You can create the configurable service by launching an IBM Integration Bus command console and then using the following command:

mqsicreateconfigurableservice IB9NODE -c JDBCProviders -o LOGDB -n databaseName,databaseType,databaseVersion,jarsURL,portNumber, serverName,type4DatasourceClassName,type4DriverClassName -v LOGDB,DB2,9.7,"C:\Program Files\IBM\SQLLIB\java",50000, localhost,com.ibm.db2.jcc.DB2XADataSource,com.ibm.db2.jcc.DB2Driver

If the user id under which you run the IBM Integration Bus node does not have authority to access the database, you will also need to run the mqsisetdbparms command to authorize the flow to insert data into the database.

Deploy converted resources

  1. IBM Integration Bus resources (Integration Services) are provided to simulate the Realtime and Delayed services with which the StockQuoteService communicates. Import RealtimeService and DelayedService from the project interchange file named PI_IIB_StubServices.zip which is provided with this article.
  2. Create a Broker Archive file inside a project in your Integration Toolkit workspace (such as inside IIB_StockQuote for example), and on the Prepare tab, select the application IIB_StockQuote , and the two Integration Services DelayedService and RealtimeService :
    Broker Archive File
    图10
  3. Click the Build and Save button and then deploy the BAR file to your default configuration:
    Deployed resources
    图11

Test converted resources

A test tool (called JMSUtil) is provided with this article which can be used to write a JMS message of the correct format to the input queue, and retrieve the response message which IBM Integration Bus will write to the reply queue.

  1. Open an IBM Integration Bus Command Console and (assuming you followed the instructions earlier in the article) change directory to C:\Resources .
  2. The JMSUtil application needs access to the JMS libraries provided with WebSphere MQ, so assuming you installed WMQ to the default location, launch the application with the command shown below:
    java -jar JMSUtil.jar -cp "C:\Program Files (x86)\IBM\WebSphere MQ\java\lib"
  3. JMSUtil is launched with the correct settings pre-configured for the JMS bindings discussed earlier in the article, so the Connection tab properties will already have been set for you, as shown below:
    JMSUtil Connection Properties
    图12

    Switch to the Header tab properties and you will see that the JMSReplyTo queue has also been defined for you to match with the definition we created earlier.
    JMSUtil Header Properties
    图13

    Switch to the Data tab properties and you will see that the data carried in the body of the message has also been defined. If you wish to change the message when doing your own testing, you can edit the text directly using your keyboard:
    JMSUtil Data
    图14

    Switch back to the Connection tab properties and click the Write Message button. The Status and Current Queue Depth properties will be updated to show the message has been written to the queue successfully:
    JMSUtil Data Written to the queue successfully
    Figure 15
  4. Assuming the IBM Integration Bus flow has executed successfully all the way through, we will now read the response message from the queue. Change the JMS Destination Name to be StockQuoteServiceResponse and click the Read Message button. The Status should show a successful read has occurred, and the Current Queue Depth should now read as zero (the message has just been taken from the response queue):
    JMSUtil message read from the response queue successfully
    Figure 16
  5. Switch to the Data properties tab and you should see that it contains the response message which came from the IIB_StockQuote service:
    JMSUtil data view of the response message
    Figure 17

Check Log database

The Log subflow which was used as the replacement for the Message Logger primitive should have copied the input message which was propagated through the IBM Integration Bus flow into the DATAWAREHOUSE table of the LOGDB database which we created earlier. Open a DB2 Control Center and check the contents of the table. You should see something like . The input message to the StockQuote service has been logged with a timestamp.

Message logged to the DB2 database
Figure 18

结论

IBM Integration Bus V9是IBM的新战略集成产品(基于与WebSphere Message Broker相同的体系结构构建)。 Integration Bus Toolkit提供了用于转换构建时资源的第一功能,该构建时资源最初是为支持WebSphere Enterprise Service Bus用例而创建的。 本文演示了如何使用该工具转换简单的中介,并且还讨论了两种产品之间的一些体系结构差异。 本系列的第二篇文章涉及一个基于WebSphere Enterprise Service Bus StockQuote示例的更复杂的场景,该示例显示了要转换的更广泛的中介原语,还讨论了转换工具的扩展点。


翻译自: https://www.ibm.com/developerworks/websphere/library/techarticles/1308_thompson2/1308_thompson2.html

进程原语和线程原语是啥意思

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值