我正在尝试使用下面的FunctionalTestCase向VM端点发送消息:
@Test
public void CreateAddToCalendarOptionsApiTest() throws Exception{
MuleClient client = new MuleClient(muleContext);
String payload = "foo";
Map<String, Object> properties = null;
MuleMessage result = client.send("vm://processActivity", payload, properties);
assertEquals("foo Received", result.getPayloadAsString());
}
但是,在要测试的流程中,定义了多个VM连接器,因此我收到一条说明的TransportFactoryException:
org.mule.transport.service.TransportFactoryException: There are at least
2 connectors matching protocol "vm", so the connector to use must be
specified on the endpoint using the 'connector' property/attribute.
Connectors in your configuration that support "vm" are: inMemoryVMQueue,
recordDeletedActivityDLQStore, recordPublishedActivityDLQStore,
recordUpdatedActivityDLQStore, deleteQueuedActivityDLQStore,
(java.lang.IllegalStateException)
如何指定client.send(“vm:// processActivity”,payload,properties)使用特定的VMConnector?
答案 0 :(得分:7)
使用查询参数:
client.send("vm://processActivity?connector=inMemoryVMQueue", payload, properties);
...用您想要使用的连接器替换inMemoryVMQueue
。
它在功能上等同于端点属性。
答案 1 :(得分:0)
“vm:// test?connector = VM”在查询路径中定义如下
public void test() throws MuleException{
MuleMessage message = new DefaultMuleMessage("ts",muleContext);
MuleMessage reply = muleContext.getClient().send("vm://test?connector=VM", message);
}