如何将 jms 作为 json 格式 (SyndEntryImpl)

how to jms as a json format (SyndEntryImpl)

这是我的 spring 集成配置:

 <int-feed:inbound-channel-adapter id="feedAdapter"
                                      channel="feedChannel"
                                      auto-startup="true"
                                      url="https://whosebug.com/feeds/question/49479712">
        <int:poller fixed-rate="10000" max-messages-per-poll="100"/>
    </int-feed:inbound-channel-adapter>

    <int:channel id="feedChannel"/>

    <int:chain input-channel="feedChannel" output-channel="feedOutputChannel">
        <int:transformer id="transformer"
                         expression="@confbean"/>
        <int:object-to-json-transformer/>
    </int:chain>

    <bean id="confbean" class="com.xml.urlfeed.Feed">
        <property name="title" value="payload.title" />
        <property name="author" value="payload.author" />
    </bean>

    <int:channel id="feedOutputChannel"/>

    <jms:outbound-channel-adapter id="jmsOutGateway"
                                  channel="feedOutputChannel"
                                  destination="inputQueue"/>
public class Feed {
    private String title;
    private String author;
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getAuthor() {
        return author;
    }
    public void setAuthor(String author) {
        this.author = author;
    }
}

Feed xml 中的一些条目。

SyndEntryImpl.title=Test123
SyndEntryImpl.authors[0].name=Quentin

基本上我希望它以 json 格式发送到 activemq queue。

我通过 spring 配置获得了什么信息:

{"title":"payload.title","author":"payload.author"}

但这不是我想要的结果。这就是我想要的样子:

{"title":"Test123","author":"Quentin"}

我如何从 SyndEntryImpl 向标题和作者声明我可以将它作为 json 格式发送到 activemq,稍后我可以将此消息作为 json 格式使用并且将其转换为 object?

我认为我需要解决此问题才能使其正常工作:

<property name="title" value="payload.title" />
<property name="author" value="payload.author" />

但是我该如何更改 value?它可以与 SyndEntryImpl 一起使用。

那个bean是静态的;你需要使用这样的东西...

expression="new com.foo.Feed(payload.title, payload.author)"

...通过添加构造函数。