'Can I send/receive Java objects to RabbitMQ using Java built-in IO classes instead of Spring AMQP?

I need to send/receive Java POJOs to/from RabbitMQ. There is a ready solution with Spring AMQP, but I've managed to do it with built-in java.io.* (serialize POJO into byte array with ObjectOutputStream + ByteArrayOutputStream and send it to RabbitMQ; on the other side the process is reversed). Is it an equally efficient/safe solution?

Edit

I am using com.rabbitmq.client.* library for connections, channels, queues, etc. I was just wondering if I can send objects to RabbitMQ by serializing them into byte arrays using standard classes from java.io.* package, and leave Spring AMQP aside



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source