- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在通过 Java 将 JAXB 对象发送到 Rabbit MQ。
JAXBContext jaxbContext = JAXBContext.newInstance(MyDTO.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// output pretty printed
jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
java.io.StringWriter sw = new StringWriter();
jaxbMarshaller.marshal(deliveryrequest, sw);
ConnectionFactory factory = new ConnectionFactory() ;
//TODO change the hardcoding to the properties file
factory.setHost("rabbitmq.host.net");
factory.setUsername("user");
factory.setPassword("pass");
Channel channel ;
Connection connection;
Map<String, Object> args = new HashMap<String, Object>();
String haPolicyValue = "all";
args.put("x-ha-policy", haPolicyValue);
connection = factory.newConnection();
channel = connection.createChannel();
//TODO change the hardcoding to the properties file
channel.queueDeclare("upload.com.some.queue", true, false, false, args);
//TODO change the hardcoding to the properties file
channel.basicPublish("com.some.exchange", "someroutingKey",
new AMQP.BasicProperties.Builder().contentType("text/plain")
.deliveryMode(2).priority(1).userId("guest").build(),
sw.toString().getBytes());
我在不同的应用程序中使用 Camel 来阅读这篇文章。
<camel:route id="myRoute">
<camel:from uri="RabbitMQEndpoint" />
<camel:to uri="bean:MyHandler" />
</camel:route>
处理程序正在使用 Camel 端重做的 Jaxb 对象
@Handler
public void handleRequest(MyDTO dto) throws ParseException {
我收到了我没想到的错误。
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: byte[] to the required type: com.mycompany.MyDTO with value [B@1b8d3e42
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:181)
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
感谢解决方案。
最佳答案
你从 rabbit 传来的消息体类型是一个 byte[],你想调用一个 MyDTO 类型的 bean。您的类型不匹配。并且 Camel 找不到可以将消息正文从 byte[] 转换为您的 MyDTO 类型的类型转换器。
Rabbit 的 byte[] 数据是 XML 格式的吗?您是否在 MyDTO 类上有 JAXB 注释,以便您可以使用 JAXB 将其从 xml 编码到 Java?
关于jaxb - org.apache.camel.InvalidPayloadException : No body available of type error thrown while unMarshalling Jaxb Object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19169267/
在运行我的单元测试时,有时,即使它们通过了,在所有测试运行结束时,我也会收到以下错误。 在运行 PhantomJS 的 Jenkins CI 构建中: .PhantomJS 2.1.1 (Linux
当我在我的 Angular 项目中运行 ng test 命令时出现错误,它给出了这样的错误 10% building modules 1/1 modules 0 active04 12 2018 11
当我进行 Angular 4 单元测试时,其中一个使用 google maps 和 agm 包的页面显示错误: An error was thrown in afterAll\n[object Err
我的“JavaClassLoader”库有问题。我想为应用程序编写一个启动器。最后应该可以关闭程序、更新并重新启动。现在,当我尝试使用参数调用方法时,我总是得到 NoSuchMethodEx。 我想要
我收到的异常是 Exception thrown at 0x70F8516F (vcruntime140d.dll) in Project.exe: 0xC0000005: Access violat
本周两次,我读到有人写过一个事件 (.net) 被“抛出”。我一直认为用于事件的动词是“fire”或“raise”。我认为“thrown”用于异常,而不是用于事件(“raise”可用于任何一个)。 有
我得到的完整错误是这个。 在“FooBlogBundle:Article:articles.html”中呈现模板期间抛出异常(“缺少一些强制性参数(“id”)以生成路由“FooBlogBund
我正在做一些调试,我真的想打开“抛出异常时中断”选项。我依赖的第三方程序集会定期抛出异常。其中一些,例如 SynchronizationLockException,我可以通过 Debug -> Exc
我的家庭作业有问题。我们的作业由在线网站评分,我不断收到有关下面显示的代码的以下错误。 错误: Exception conditions. Incorrect exception thrown for
我正在尝试通过 ./spark-submit 向 Spark 提交申请。 我用java构建了一个jar,代码如下: import org.apache.spark.SparkConf; import
我的应用程序(基于 vlcj 的音乐播放器)有一个非常奇怪的行为。我使用 ConcurrentHashMap 来缓存有关艺术家的信息。 如果我在 HashMap 上调用 get ,程序似乎会停止,但不
我的网页上有一个下拉列表,其中的选定项目必须传递给数据库中的存储过程查询。但是,我的绑定(bind)方法中的 adp.Fill(ds) 出现了一个奇怪的错误。 异常总是显示“关键字‘to’附近的语法不
创建 javaodc 时,您描述了您的方法可以抛出的异常,对吗? 看例子: public void createLogFile() { try { file.createNe
当我运行我的应用程序时,出现错误:抛出另一个异常:类型 'String' 不是 'index' 类型 'int' 的子类型 我的 android 屏幕立即因上述错误而变红,但只是片刻。之后恢复正常。我
这并不特别适用于任何语言,但如果重要的话,我在 Visual Studio 2008 中使用 VB.NET。 我似乎无法找到任何关于这个主题的真正有用的东西,但我想知道当抛出和捕获异常但由于它已被抛出
当我跑 nuget restore从命令行,我得到 Error parsing solution file at MyProject.sln: Exception has been thrown by
我是 flutter 的新手,每次运行应用程序时都会出错: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═════════════════════════════
Edit: Visual Studio 2015's new exception window is so much faster than the old dialog that I no long
这是一个常见问题的奇怪变种。 我正在使用 headless Firefox 浏览器运行 Selenium 项目。 我得到了常见的NoSuchElementExceptions。这不是什么新鲜事。但是,
我有一个在 vs 2012 Ultimate 中开发的 ssis 项目。我使用项目部署模型,并将项目设置为在 32 位模式下运行。该包在我的开发环境中执行时没有错误,但是当我将其部署到 ssis 目录
我是一名优秀的程序员,十分优秀!