设置可从 Scala 序列化的 ActiveMQ Objectmessage
Setting ActiveMQ Objectmessage serializable from Scala
在 ActiveMQ 版本更改(从 5.9.0 r4 到 r4)之后,有必要显式标记 ActiveMQ 的 ObjectMessage
可序列化,如下所示:http://activemq.apache.org/objectmessage.html。按照建议 (-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*"
) 设置环境变量工作正常,但是,在我们的案例中这不是一个优雅的解决方案。我需要从 Scala 源代码进行设置。目前连接设置如下:
val properties = new java.util.Properties()
properties.setProperty(javax.naming.context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory")
properties.setProperty(javax.naming.context.PROVIDER_URL, "tcp://localhost:61616")
val context = new InitialContext(properties)
val topicConnection = context.lookup("ConnectionFactory").asInstanceOf[TopicConnectionFactory].createTopicConnection
我找不到可以插入建议 factory.setTrustAllPackages(true)
的地方。谁能告诉我们如何在我们的案例中执行此操作,或者如何从 Scala 设置 org.apache.activemq.SERIALIZABLE_PACKAGES
环境变量?谢谢!
我刚刚添加了以下静态代码行并且它起作用了:
System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES", """*""")
在 ActiveMQ 版本更改(从 5.9.0 r4 到 r4)之后,有必要显式标记 ActiveMQ 的 ObjectMessage
可序列化,如下所示:http://activemq.apache.org/objectmessage.html。按照建议 (-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*"
) 设置环境变量工作正常,但是,在我们的案例中这不是一个优雅的解决方案。我需要从 Scala 源代码进行设置。目前连接设置如下:
val properties = new java.util.Properties()
properties.setProperty(javax.naming.context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory")
properties.setProperty(javax.naming.context.PROVIDER_URL, "tcp://localhost:61616")
val context = new InitialContext(properties)
val topicConnection = context.lookup("ConnectionFactory").asInstanceOf[TopicConnectionFactory].createTopicConnection
我找不到可以插入建议 factory.setTrustAllPackages(true)
的地方。谁能告诉我们如何在我们的案例中执行此操作,或者如何从 Scala 设置 org.apache.activemq.SERIALIZABLE_PACKAGES
环境变量?谢谢!
我刚刚添加了以下静态代码行并且它起作用了:
System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES", """*""")