【问题标题】:Read database in mule in between a flow in mule在 mule 中的流之间读取 mule 中的数据库
【发布时间】:2013-09-24 14:43:03
【问题描述】:

我正在与 MULE 一起探索的第二周。 我的要求是根据来自 http 端点的输入读取数据库或读取文件。 我试图在流程中使用 CHOICE 并确定输入的性质,然后以不同的方向流出。 但我的问题是我不确定如何使用查询值或文件值设置消息。

任何人都可以帮助我输入一些信息吗?

【问题讨论】:

    标签: mule mule-studio


    【解决方案1】:

    请查看此模块

    https://github.com/mulesoft/mule-requester-module

    它可以在流中的任何点请求资源。它用于最初仅由消息源请求的资源。

    用例是:

    • 在流​​程中间加载文件
    • 使用流中间队列中的消息(一条、N 条、全部)。
    • 按需从邮件服务器拉取邮件,例如在扩充器中使用其数据。

    它是围绕典型 muleContext.getClient() 调用的简单 devkit 包装器

    public Object request(String resource, @Optional @Default("1000") long timeout, @Optional String returnClass, @Optional Boolean throwExceptionOnTimeout) throws MuleException {
            MuleMessage message = muleContext.getClient().request(resource, timeout);
            Object result = null;
            if (message != null)
            {
                result = message.getPayload();
                if (returnClass != null)
                {
                    try {
                        Transformer transformer = muleContext.getRegistry().lookupTransformer(DataTypeFactory.create(result.getClass()), DataTypeFactory.create(Class.forName(returnClass)));
                        result = transformer.transform(result);
                    } catch (ClassNotFoundException e) {
                        throw new DefaultMuleException(e);
                    }
                }
            } else if (Boolean.TRUE.equals(throwExceptionOnTimeout))
            {
                throw new DefaultMuleException("No message received in the configured timeout - " + timeout);
            }
            return result;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-31
      • 1970-01-01
      相关资源
      最近更新 更多