3
我正在尋找啓動嵌入最小外部依賴(無彈簧等)的騾子3。任何暗示如何這樣做將不勝感激。謝謝。如何啓動嵌入最小依賴關係的Mule 3?
我正在尋找啓動嵌入最小外部依賴(無彈簧等)的騾子3。任何暗示如何這樣做將不勝感激。謝謝。如何啓動嵌入最小依賴關係的Mule 3?
以下示例使用入站VM端點和字符串appender轉換器創建流。我相信它應該讓你開始。
MuleContext context = new DefaultMuleContextFactory().createMuleContext();
MuleRegistry registry = context.getRegistry();
EndpointBuilder testEndpointBuilder = new EndpointURIEndpointBuilder("vm://testFlow.in",
context);
testEndpointBuilder.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE);
registry.registerEndpointBuilder("testFlow.in", testEndpointBuilder);
InboundEndpoint vmInboundEndpoint = testEndpointBuilder.buildInboundEndpoint();
registry.registerEndpoint(vmInboundEndpoint);
StringAppendTransformer stringAppendTransformer = new StringAppendTransformer(" world");
stringAppendTransformer.setMuleContext(context);
Flow testFlow = new Flow("testFlow", context);
testFlow.setMessageSource(vmInboundEndpoint);
testFlow.setMessageProcessors(Arrays.asList((MessageProcessor) stringAppendTransformer));
registry.registerFlowConstruct(testFlow);
context.start();
MuleClient muleClient = new MuleClient(context);
MuleMessage response = muleClient.send("vm://testFlow.in", "hello", null);
Validate.isTrue(response.getPayloadAsString().equals("hello world"));
muleClient.dispose();
context.stop();
嗨大衛,非常感謝你。我認爲我們需要一個registry.initialise();在context.getRegistry()之後 - 騾子抱怨失蹤生命階段,否則。工作得很好!需要的依賴是:commons-beanutils,commons-collections,commons-io,commons-lang,commons-logging,commons-pool,dom4j,geronimo-j2ee-connector,jaxen,與mule-embedded一起使用的jug等同於5.6M - 不錯。 – SorinS 2012-02-07 11:22:30
奇怪的是,代碼原樣對我(Mule 3.2.1)。 – 2012-02-07 16:22:38
現在它也適用於我 - 我必須有一個依賴失蹤導致它的某個點。再次感謝。 – SorinS 2012-02-07 16:50:03