use of org.springframework.core.serializer.Serializer in project spring-integration by spring-projects.
the class TcpNetConnection method send.
@Override
@SuppressWarnings("unchecked")
public synchronized void send(Message<?> message) throws Exception {
if (this.socketOutputStream == null) {
int writeBufferSize = this.socket.getSendBufferSize();
this.socketOutputStream = new BufferedOutputStream(this.socket.getOutputStream(), writeBufferSize > 0 ? writeBufferSize : 8192);
}
Object object = this.getMapper().fromMessage(message);
this.lastSend = System.currentTimeMillis();
try {
((Serializer<Object>) this.getSerializer()).serialize(object, this.socketOutputStream);
this.socketOutputStream.flush();
} catch (Exception e) {
this.publishConnectionExceptionEvent(new MessagingException(message, "Failed TCP serialization", e));
this.closeConnection(true);
throw e;
}
if (logger.isDebugEnabled()) {
logger.debug(getConnectionId() + " Message sent " + message);
}
}
use of org.springframework.core.serializer.Serializer in project spring-integration by spring-projects.
the class TcpNioConnection method send.
@Override
@SuppressWarnings("unchecked")
public void send(Message<?> message) throws Exception {
synchronized (this.socketChannel) {
if (this.bufferedOutputStream == null) {
int writeBufferSize = this.socketChannel.socket().getSendBufferSize();
this.bufferedOutputStream = new BufferedOutputStream(this.getChannelOutputStream(), writeBufferSize > 0 ? writeBufferSize : 8192);
}
Object object = this.getMapper().fromMessage(message);
this.lastSend = System.currentTimeMillis();
try {
((Serializer<Object>) this.getSerializer()).serialize(object, this.bufferedOutputStream);
this.bufferedOutputStream.flush();
} catch (Exception e) {
this.publishConnectionExceptionEvent(new MessagingException(message, "Failed TCP serialization", e));
this.closeConnection(true);
throw e;
}
if (logger.isDebugEnabled()) {
logger.debug(getConnectionId() + " Message sent " + message);
}
}
}
use of org.springframework.core.serializer.Serializer in project spring-integration by spring-projects.
the class JdbcChannelMessageStore method setSerializer.
/**
* A converter for serializing messages to byte arrays for storage.
* @param serializer The serializer to set
*/
@SuppressWarnings("unchecked")
public void setSerializer(Serializer<? super Message<?>> serializer) {
Assert.notNull(serializer, "The provided serializer must not be null.");
this.serializer = new SerializingConverter((Serializer<Object>) serializer);
}
Aggregations