【问题标题】:How can I start Mule 3 embedded with minimum dependencies?如何启动具有最小依赖项的 Mule 3?
【发布时间】:2016-09-20 18:58:59
【问题描述】:

我希望以最少的外部依赖(无弹簧等)开始嵌入 mule 3。任何有关如何执行此操作的提示将不胜感激。谢谢你。

【问题讨论】:

    标签: java mule


    【解决方案1】:

    以下示例使用入站 VM 端点和字符串附加转换器创建流。我相信它应该让你开始。

        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,jug 与 mule-embedded 一起相当于 5.6M - 不错。
    • 它现在也对我有用 - 我一定是在某些时候丢失了一个导致它的依赖项。再次感谢。
    猜你喜欢
    • 2021-10-07
    • 2019-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 2020-12-01
    • 1970-01-01
    相关资源
    最近更新 更多