Reply received after timeout - java

I want to register two queues listeners for Spring AMQP with the latest Spring version:
#Bean
public SimpleMessageListenerContainer processingTransactionSaleContainer(ConnectionFactory cf, TransactionElavonSaleListener listener) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
container.setQueueNames(QUEUE_PROCESSING_SALE);
container.setMessageListener(new MessageListenerAdapter(listener, "transactionSaleProcess"));
container.setMessageConverter(new SerializerMessageConverter());
return container;
}
#Bean
public SimpleMessageListenerContainer processingTransactionAuthorizeContainer(ConnectionFactory cf, TransactionAuthorizeListener listener) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
container.setQueueNames(QUEUE_PROCESSING_AUTHORIZE);
container.setMessageListener(new MessageListenerAdapter(listener, "transactionAuthorizeProcess"));
container.setMessageConverter(new SerializerMessageConverter());
return container;
}
Listener:
#Component
public class TransactionElavonSaleListener {
public TransactionResponseFactory transactionElavonSaleProcess(TransactionRequestFactory ro) {
..... do some heavy network request
return parseRawSuccessResponse(response);
}
}
When I remove one of the SimpleMessageListenerContainer it's working file but when I use the both methods I get this exception:
00:40:14,469 INFO [stdout] (pool-9-thread-5) 00:40:14.468 [pool-9-thread-5] WARN o.s.amqp.rabbit.core.RabbitTemplate - Reply received after timeout for 1
00:40:14,472 INFO [stdout] (pool-9-thread-5) 00:40:14.472 [pool-9-thread-5] WARN o.s.a.r.l.ConditionalRejectingErrorHandler - Execution of Rabbit message listener failed.
00:40:14,473 INFO [stdout] (pool-9-thread-5) org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Listener threw exception
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.wrapToListenerExecutionFailedExceptionIfNeeded(AbstractMessageListenerContainer.java:1613)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1517)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1440)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1428)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:1423)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1372)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer$SimpleConsumer.callExecuteListener(DirectMessageListenerContainer.java:995)
00:40:14,473 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer$SimpleConsumer.handleDelivery(DirectMessageListenerContainer.java:955)
00:40:14,474 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:149)
00:40:14,474 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:104)
00:40:14,474 INFO [stdout] (pool-9-thread-5) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
00:40:14,474 INFO [stdout] (pool-9-thread-5) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
00:40:14,478 INFO [stdout] (pool-9-thread-5) at java.base/java.lang.Thread.run(Thread.java:844)
00:40:14,481 INFO [stdout] (pool-9-thread-5) Caused by: org.springframework.amqp.AmqpRejectAndDontRequeueException: Reply received after timeout
00:40:14,494 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.core.RabbitTemplate.onMessage(RabbitTemplate.java:2446)
00:40:14,494 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectReplyToMessageListenerContainer.lambda$setMessageListener$1(DirectReplyToMessageListenerContainer.java:115)
00:40:14,494 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1514)
00:40:14,494 INFO [stdout] (pool-9-thread-5) ... 11 common frames omitted
00:40:14,495 INFO [stdout] (pool-9-thread-5) 00:40:14.495 [pool-9-thread-5] ERROR o.s.a.r.l.DirectReplyToMessageListenerContainer - Failed to invoke listener
00:40:14,495 INFO [stdout] (pool-9-thread-5) org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Listener threw exception
00:40:14,495 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.wrapToListenerExecutionFailedExceptionIfNeeded(AbstractMessageListenerContainer.java:1613)
00:40:14,495 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1517)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1440)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1428)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:1423)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1372)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer$SimpleConsumer.callExecuteListener(DirectMessageListenerContainer.java:995)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer$SimpleConsumer.handleDelivery(DirectMessageListenerContainer.java:955)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:149)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:104)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
00:40:14,496 INFO [stdout] (pool-9-thread-5) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
00:40:14,497 INFO [stdout] (pool-9-thread-5) at java.base/java.lang.Thread.run(Thread.java:844)
00:40:14,497 INFO [stdout] (pool-9-thread-5) Caused by: org.springframework.amqp.AmqpRejectAndDontRequeueException: Reply received after timeout
00:40:14,497 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.core.RabbitTemplate.onMessage(RabbitTemplate.java:2446)
00:40:14,497 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.DirectReplyToMessageListenerContainer.lambda$setMessageListener$1(DirectReplyToMessageListenerContainer.java:115)
00:40:14,497 INFO [stdout] (pool-9-thread-5) at deployment.rest_api.war//org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1514)
00:40:14,497 INFO [stdout] (pool-9-thread-5) ... 11 common frames omitted
Do you know why I get this exception when I have these two methods?
EDITL Defined listeners:
#Bean
public SimpleMessageListenerContainer processingTransactionElavonSaleContainer(ConnectionFactory cf, TransactionElavonSaleListener listener) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
container.setQueueNames(QUEUE_PROCESSING_ELAVON_SALE);
container.setMessageListener(new MessageListenerAdapter(listener, "transactionElavonSaleProcess"));
return container;
}
#Bean
public SimpleMessageListenerContainer processingTransactionElavonAuthorizeContainer(ConnectionFactory cf, TransactionElavonAuthorizeListener listener) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
container.setQueueNames(QUEUE_PROCESSING_ELAVON_AUTHORIZE);
container.setMessageListener(new MessageListenerAdapter(listener, "transactionElavonAuthorizeProcess"));
return container;
}
...
#Component
public class TransactionElavonSaleListener {
public TransactionResponseFactory transactionElavonSaleProcess(TransactionRequestFactory ro) {
return new TransactionResponseFactory();
}
}
#Component
public class TransactionElavonAuthorizeListener {
public TransactionResponseFactory transactionElavonAuthorizeProcess(TransactionRequestFactory tf) {
TransactionResponseFactory obj = new TransactionResponseFactory();
return obj;
}
}
Send object:
TransactionResponseFactory processingPeply = (TransactionResponseFactory) processingTransactionElavonAuthorizeTemplate.convertSendAndReceive(
ContextServer.EXCHANGE_PROCESSING, ContextServer.ROUTING_KEY_PROCESSING_TRANSACTION_ELAVON, tf);
System.out.println("!!!!! Received PROCESSING_TRANSACTION " + processingPeply.getTransaction_id());

Observation about your configuration (not relevant to your issue, however)...
The declare... code in your AmqpAdmin are not required.
you should never interact with the broker during the bean definition phase - it's too early.
they are not necessary because the admin will find the Queue and Exchange beans and automatically declare them for you when the connection is first opened.
Yes, that message converter setter is not used for this kind of listener; the message converter should be set on the MessageListenerAdapter instead.
However, it gets a SimpleMessageConverter by default so that should not be the problem; this converter handles serialized objects as well as plain text.
Now, to your actual issue; adding a second container should not have any affect on the client side; each template gets its own reply container and direct reply-to is used by default so there will be no cross talk between them (which can happen if you use a named reply queue, but that's not the case here).
I suggest you turn on DEBUG logging to figure out what's going on; if you need help analyzing them; post the logs (from both client and server side) and I'll take a look.
EDIT
Your bindings are incorrect:
#Bean
public Binding bindingQueueProcessingElavonSale() {
return BindingBuilder.bind(new Queue(QUEUE_PROCESSING_ELAVON_SALE, true))
.to(new TopicExchange(EXCHANGE_PROCESSING)).with(ROUTING_KEY_PROCESSING_TRANSACTION_ELAVON);
}
#Bean
public Binding bindingQueueProcessingElavonAuthorize() {
return BindingBuilder.bind(new Queue(QUEUE_PROCESSING_ELAVON_AUTHORIZE, true))
.to(new TopicExchange(EXCHANGE_PROCESSING)).with(ROUTING_KEY_PROCESSING_TRANSACTION_ELAVON);
}
You are binding both queues to the same exchange with the same routing key - RabbitMQ will send messages with that routing key to both queues, so both listeners will respond.

Default timeout for convertSendAndReceive is 5 seconds. To modify the timeout set property replyTimeout of AmqpTemplate to bigger value (milliseconds).
https://docs.spring.io/spring-amqp/reference/html/#reply-timeout

Related

Nested Executors using FixedThreadPool

I'm trying to implement a ExecutorService nested within another Executor. The parent executor is a FixedThreadPool of size 5, while the nested Executor is of size 10. While running it, i see the following in the logger going from "[pool-2-thread-1]" to [pool-50-thread-9]. I understand thread count going between 1 to 10 and back because the child Executor is of size 10. But why does the pool count go from 1 to 50+ and so on. Are there any memory leaks or is it because I'm shutting down the executor each time and recreating the threads
private ExecutorService executors=Executors.newFixedThreadPool(5);
executors.execute(new Runnable() {
#Override
public void run() {
try {
//code
logger.info(message);
ExecutorService childThreads = Executors.newFixedThreadPool(10);
for(Map<String, Object> entity: listOfEntities){
childThreads.execute(new Runnable() {
#Override
public void run() {
try {
//code
logger.info(message);
//code
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
childThreads.shutdown();
Long shutDownTime=System.currentTimeMillis();
while(!childThreads.isTerminated()) {
if((System.currentTimeMillis()-shutDownTime)>60000) {
childThreads.shutdownNow();
childThreads.awaitTermination(2, TimeUnit.SECONDS);
break;
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
});
`
This is what i see in Logger:
2019-08-02 04:01:04.052 INFO 45844 --- [pool-6-thread-4]
2019-08-02 04:01:04.055 INFO 45844 --- [pool-6-thread-2]
2019-08-02 04:01:04.057 INFO 45844 --- [pool-9-thread-2]
2019-08-02 04:01:04.069 INFO 45844 --- [pool-5-thread-5]
2019-08-02 04:01:04.197 INFO 45844 --- [pool-9-thread-1]
2019-08-02 04:01:04.199 INFO 45844 --- [pool-8-thread-5]
2019-08-02 04:01:04.641 INFO 45844 --- [pool-9-thread-8]
2019-08-02 04:01:04.641 INFO 45844 --- [pool-5-thread-2]
2019-08-02 04:01:04.650 INFO 45844 --- [pool-7-thread-5]
2019-08-02 04:01:04.692 INFO 45844 --- [pool-5-thread-1]
2019-08-02 04:01:04.713 INFO 45844 --- [pool-8-thread-6]
2019-08-02 04:01:04.715 INFO 45844 --- [pool-8-thread-7]
2019-08-02 04:01:04.728 INFO 45844 --- [pool-7-thread-3]
2019-08-02 04:01:05.062 INFO 45844 --- [pool-5-thread-6]
2019-08-02 04:01:05.067 INFO 45844 --- [pool-8-thread-2]
2019-08-02 04:01:05.515 INFO 45844 --- [pool-6-thread-6]
2019-08-02 04:01:05.532 INFO 45844 --- [pool-8-thread-4]
2019-08-02 04:01:05.533 INFO 45844 --- [pool-5-thread-3]
2019-08-02 04:01:05.554 INFO 45844 --- [pool-9-thread-3]
2019-08-02 04:01:05.554 INFO 45844 --- [pool-9-thread-4]
2019-08-02 04:01:05.584 INFO 45844 --- [pool-8-thread-1]
2019-08-02 04:01:05.654 INFO 45844 --- [pool-7-thread-4]
2019-08-02 04:01:05.991 INFO 45844 --- [pool-5-thread-4]
2019-08-02 04:01:06.349 INFO 45844 --- [pool-7-thread-2]
2019-08-02 04:01:06.405 INFO 45844 --- [pool-9-thread-7]
2019-08-02 04:01:06.405 INFO 45844 --- [pool-6-thread-5]
2019-08-02 04:01:06.405 INFO 45844 --- [pool-6-thread-1]
2019-08-02 04:01:06.448 INFO 45844 --- [pool-9-thread-5]
2019-08-02 04:01:06.448 INFO 45844 --- [pool-9-thread-6]
2019-08-02 04:01:06.448 INFO 45844 --- [pool-6-thread-3]
2019-08-02 04:01:06.525 INFO 45844 --- [pool-7-thread-6]

NamedParameterJdbcTemplate NOT SUPPORT SUM()?

I'm using NamedParameterJdbcTemplate,below SQL works well in Oraclie SQL Developer.
select sum(PRINTEDLICNUM), sum(PRINTEDLICCOPYNUM), PRIPID from LICENSEPRINTRECORD where PRIPID in ('370212230027855') GROUP BY PRIPID;
But this code not works in NamedParameterJdbcTemplate
Map namedParameters = Collections.singletonMap("pripids", pripIds);
StringBuffer recordQueryString = new StringBuffer();
recordQueryString.append("SELECT SUM(PRINTEDLICNUM), SUM(PRINTEDLICCOPYNUM), PRIPID from LICENSEPRINTRECORD where PRIPID in (:pripids) GROUP BY PRIPID");
List<PreviousPrintRecords> records = template.query(recordQueryString.toString(), namedParameters, new RowMapper<PreviousPrintRecords>());
Below is my RowMapper Class:
public class PreviousPrintRecords implements Serializable{
/**
*
*/
private static final long serialVersionUID = -3763072257141955974L;
private int printedLicNum;
private int printedLicCopyNum;
private String pripId;
public PreviousPrintRecords() {
super();
}
public PreviousPrintRecords(int printedLicNum, int printedLicCopyNum, String pripId) {
super();
this.printedLicNum = printedLicNum;
this.setPrintedLicCopyNum(printedLicCopyNum);
this.pripId = pripId;
}
public int getPrintedLicNum() {
return printedLicNum;
}
public void setPrintedLicNum(int printedLicNum) {
this.printedLicNum = printedLicNum;
}
public String getPripId() {
return pripId;
}
public void setPripId(String pripId) {
this.pripId = pripId;
}
public int getPrintedLicCopyNum() {
return printedLicCopyNum;
}
public void setPrintedLicCopyNum(int printedLicCopyNum) {
this.printedLicCopyNum = printedLicCopyNum;
}
}
It will occurs error, nested exception is java.sql.SQLException: Invalid column name
below is detailed trace:
10:48:09,477 INFO [stdout] (DefaultThreadPoolService1) 2018-05-15 10:48:09 INFO o.s.j.support.SQLErrorCodesFactory - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) 2018-05-15 10:48:09 ERROR c.a.p.a.task.GetLicenseItemListTask - Get licenseitem task occurs error org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT SUM(PRINTEDLICNUM), SUM(PRINTEDLICCOPYNUM), PRIPID from LICENSEPRINTRECORD where PRIPID in (?, ?, ?, ?, ?, ?, ?) GROUP BY PRIPID]; nested exception is java.sql.SQLException: Invalid column name
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:649)
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:684)
10:48:09,532 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:711)
10:48:09,533 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:761)
10:48:09,533 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:192)
10:48:09,533 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:199)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at com.aw.product.abp.licenseprint.service.DaoLicensePrintService.requestLicensePrintItemData(DaoLicensePrintService.java:167)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at com.aw.product.abp.task.GetLicenseItemListTask.run(GetLicenseItemListTask.java:85)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at java.util.concurrent.FutureTask.run(FutureTask.java:266)
10:48:09,534 INFO [stdout] (DefaultThreadPoolService1) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) at java.lang.Thread.run(Thread.java:745)
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) Caused by: java.sql.SQLException: Invalid column name
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
10:48:09,535 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
10:48:09,537 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
10:48:09,539 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
10:48:09,539 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271)
10:48:09,539 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:445)
10:48:09,539 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3367)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:2009)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at org.jboss.jca.adapters.jdbc.WrappedResultSet.getString(WrappedResultSet.java:1381)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at com.aw.product.abp.licenseprint.service.DaoLicensePrintService$2.mapRow(DaoLicensePrintService.java:173)
10:48:09,540 INFO [stdout] (DefaultThreadPoolService1) at com.aw.product.abp.licenseprint.service.DaoLicensePrintService$2.mapRow(DaoLicensePrintService.java:1)
10:48:09,541 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
10:48:09,541 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
10:48:09,541 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:697)
10:48:09,543 INFO [stdout] (DefaultThreadPoolService1) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633)
10:48:09,543 INFO [stdout] (DefaultThreadPoolService1) ... 12 more
Does NamedParameterJdbcTemplate not support sum function?
If I wanna use sum function, is there any way to achieve this?
java.sql.SQLException: Invalid column name
The exception is clear enough. You properly named your table column name in the wrong way.
You are using rowMapper class, but you not define the column name.
Change your code as below
recordQueryString.append("SELECT SUM(PRINTEDLICNUM) AS printedLicNum, SUM(PRINTEDLICCOPYNUM) AS printedLicCopyNum, PRIPID from LICENSEPRINTRECORD where PRIPID in (:pripids) GROUP BY PRIPID");

How to respond to request with TcpInboundGateway?

I would like to develop a TCP Server with Spring Integration but I have a few difficulties...
My server should listen on a port for GPS devices which first identify themselves with their IMEI and needs an Acknowledgment from the server to go further and send the position data to the same TCP server.
I succeeded to get the IMEI but the acknowledgment doesn't reach the device... I'm not even sure if i send it the right way. I read the documentation and other posts and I found out that I had to use TcpInboundGateway instead of channel adapter because it's the same session. But do I have to use TcpOutboundGateway to send the response back to the device ?
Here is my code :
#EnableIntegration
#IntegrationComponentScan
#Configuration
public class TcpServerConfiguration {
private static final Logger logger = LogManager.getLogger(TcpServerConfiguration.class);
#Autowired
TcpServerProperties properties;
#Bean
public AbstractServerConnectionFactory serverFactory() {
TcpNetServerConnectionFactory tcpServerFactory = new TcpNetServerConnectionFactory(properties.getPort());
tcpServerFactory.setDeserializer(new ByteArrayRawSerializer());
return tcpServerFactory;
}
#Bean
public MessageChannel inputChannel() {
DirectChannel channel = new DirectChannel();
return channel;
}
#Bean
public MessageChannel outputChannel() {
DirectChannel channel = new DirectChannel();
return channel;
}
#Bean
public TcpInboundGateway tcpInGate(AbstractServerConnectionFactory connectionFactory) {
TcpInboundGateway inGateway = new TcpInboundGateway();
inGateway.setConnectionFactory(connectionFactory);
inGateway.setRequestChannel(inputChannel());
inGateway.setReplyChannel(outputChannel());
return inGateway;
}
}
The message handler class :
#MessageEndpoint
public class MessageHandler {
private static final Logger logger = LogManager.getLogger(MessageHandler.class);
#Transformer( inputChannel = "inputChannel", outputChannel = "outputChannel")
public byte[] consume(byte[] bytes) {
String message = new String(bytes);
String byteString = "";
for (byte b : bytes) {
byteString += Byte.toString(b) + ", ";
}
logger.info("Bytes : " + byteString);
logger.info("Message : " + message);
return new byte[]{ 01 };
}
}
Here I always send the Ack (01) to test if it's successfully sent which is not the case.
I added logging.level.org.springframework.integration=DEBUG and here is what I got :
2017-10-02 14:16:44.245 INFO 6340 --- [main] b.thingsplay.Fmb920TcpServerApplication : Started Fmb920TcpServerApplication in 3.885 seconds (JVM running for 5.38)
2017-10-02 14:16:44.250 INFO 6340 --- [pool-1-thread-1] .s.i.i.t.c.TcpNetServerConnectionFactory : serverFactory, port=7015 Listening
2017-10-02 14:17:50.161 DEBUG 6340 --- [pool-1-thread-1] .s.i.i.t.c.TcpNetServerConnectionFactory : Accepted connection from 1.1.1.1
2017-10-02 14:17:50.200 DEBUG 6340 --- [pool-1-thread-1] o.s.i.i.tcp.connection.TcpNetConnection : New connection ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912
2017-10-02 14:17:50.201 DEBUG 6340 --- [pool-1-thread-1] .s.i.i.t.c.TcpNetServerConnectionFactory : serverFactory: Added new connection: ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912
2017-10-02 14:17:50.204 DEBUG 6340 --- [pool-1-thread-2] o.s.i.i.tcp.connection.TcpNetConnection : ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912 Reading...
2017-10-02 14:17:50.207 DEBUG 6340 --- [pool-1-thread-2] o.s.i.i.t.s.ByteArrayRawSerializer : Available to read:17
2017-10-02 14:18:20.576 DEBUG 6340 --- [pool-1-thread-2] o.s.i.i.tcp.connection.TcpNetConnection : Message received GenericMessage [payload=byte[17], headers={ip_tcp_remotePort=62138, ip_connectionId=ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912, ip_localInetAddress=/0.0.0.0, ip_address=1.1.1.1, id=229435ad-6284-8136-40d4-4fdfe3ef462e, ip_hostname=ptr-x-x-x-x.dyn.mobistar.be, timestamp=1506946700575}]
2017-10-02 14:18:20.585 INFO 6340 --- [pool-1-thread-2] o.s.i.endpoint.EventDrivenConsumer : Adding {bridge:null} as a subscriber to the 'outputChannel' channel
2017-10-02 14:18:20.587 INFO 6340 --- [pool-1-thread-2] o.s.integration.channel.DirectChannel : Channel 'application.outputChannel' has 1 subscriber(s).
2017-10-02 14:18:20.589 INFO 6340 --- [pool-1-thread-2] o.s.i.endpoint.EventDrivenConsumer : started org.springframework.integration.endpoint.EventDrivenConsumer#14c3d44a
2017-10-02 14:18:20.595 DEBUG 6340 --- [pool-1-thread-2] o.s.integration.channel.DirectChannel : preSend on channel 'inputChannel', message: GenericMessage [payload=byte[17], headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, ip_tcp_remotePort=62138, ip_connectionId=ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912, ip_localInetAddress=/0.0.0.0, ip_address=1.1.1.1, id=2cc3d793-dc24-705d-1438-d4b3e089d11b, ip_hostname=ptr-x-x-x-x.dyn.mobistar.be, timestamp=1506946700594}]
2017-10-02 14:18:20.598 DEBUG 6340 --- [pool-1-thread-2] o.s.i.t.MessageTransformingHandler : messageHandler.consume.transformer.handler received message: GenericMessage [payload=byte[17], headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, ip_tcp_remotePort=62138, ip_connectionId=ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912, ip_localInetAddress=/0.0.0.0, ip_address=1.1.1.1, id=2cc3d793-dc24-705d-1438-d4b3e089d11b, ip_hostname=ptr-x-x-x-x.dyn.mobistar.be, timestamp=1506946700594}]
2017-10-02 14:18:20.608 INFO 6340 --- [pool-1-thread-2] be.thingsplay.tcp.MessageHandler : Bytes : 0, 15, 51, 53, 50, 48, 57, 52, 48, 56, 51, 50, 54, 54, 52, 55, 53,
2017-10-02 14:18:20.611 INFO 6340 --- [pool-1-thread-2] be.thingsplay.tcp.MessageHandler : Message : 352094083266475
2017-10-02 14:18:20.618 DEBUG 6340 --- [pool-1-thread-2] o.s.integration.channel.DirectChannel : preSend on channel 'outputChannel', message: GenericMessage [payload=byte[1], headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, ip_tcp_remotePort=62138, ip_connectionId=ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912, ip_localInetAddress=/0.0.0.0, ip_address=1.1.1.1, id=0e5b6c37-ff73-5c46-4c37-0df48d3ba607, ip_hostname=ptr-x-x-x-x.dyn.mobistar.be, timestamp=1506946700614}]
2017-10-02 14:18:20.620 DEBUG 6340 --- [pool-1-thread-2] o.s.integration.handler.BridgeHandler : org.springframework.integration.handler.BridgeHandler#5b393299 received message: GenericMessage [payload=byte[1], headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, ip_tcp_remotePort=62138, ip_connectionId=ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912, ip_localInetAddress=/0.0.0.0, ip_address=1.1.1.1, id=0e5b6c37-ff73-5c46-4c37-0df48d3ba607, ip_hostname=ptr-x-x-x-x.dyn.mobistar.be, timestamp=1506946700614}]
2017-10-02 14:18:20.623 DEBUG 6340 --- [pool-1-thread-2] o.s.integration.channel.DirectChannel : postSend (sent=true) on channel 'outputChannel', message: GenericMessage [payload=byte[1], headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, ip_tcp_remotePort=62138, ip_connectionId=ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912, ip_localInetAddress=/0.0.0.0, ip_address=1.1.1.1, id=0e5b6c37-ff73-5c46-4c37-0df48d3ba607, ip_hostname=ptr-x-x-x-x.dyn.mobistar.be, timestamp=1506946700614}]
2017-10-02 14:18:20.625 DEBUG 6340 --- [pool-1-thread-2] o.s.integration.channel.DirectChannel : postSend (sent=true) on channel 'inputChannel', message: GenericMessage [payload=byte[17], headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#1a0438a2, ip_tcp_remotePort=62138, ip_connectionId=ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912, ip_localInetAddress=/0.0.0.0, ip_address=1.1.1.1, id=2cc3d793-dc24-705d-1438-d4b3e089d11b, ip_hostname=ptr-x-x-x-x.dyn.mobistar.be, timestamp=1506946700594}]
2017-10-02 14:18:20.628 DEBUG 6340 --- [pool-1-thread-2] o.s.i.i.tcp.connection.TcpNetConnection : ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912 Message sent GenericMessage [payload=byte[1], headers={ip_tcp_remotePort=62138, ip_connectionId=ptr-x-x-x-x.dyn.mobistar.be:62138:7015:a7151dbf-63c1-4ff5-b158-5707797b8912, ip_localInetAddress=/0.0.0.0, ip_address=1.1.1.1, id=af87b495-fceb-dbdc-c768-a8a81391af75, ip_hostname=ptr-x-x-x-x.dyn.mobistar.be, timestamp=1506946700628}]
2017-10-02 14:18:20.631 DEBUG 6340 --- [pool-1-thread-2] o.s.i.i.t.s.ByteArrayRawSerializer : Available to read:0
I hope someone will be able to help me !
You use TcpInboundGateway correct way. Although you might not need setReplyChannel() option. In most cases it is fully enough to rely on the replyChannel in headers and jsut return from the #Transformer method will reach the proper "session" to reply.
I think you use wrong deserializer. See ByteArrayRawSerializer JavaDocs:
* A byte array (de)serializer that does nothing with the payload; sends it raw.
* Message termination for assembly purposes is signaled by the client closing the
* connection. The serializer does not, itself, close the connection after
* writing the bytes.
* <p>
* Because the socket must be closed to indicate message end, this (de)serializer
* can only be used by uni-directional (non-collaborating) channel adapters, and
* not by gateways.
So, since your client doesn't close the connection for end session, you don't get the reply there. More over this serializer isn't for gateways.
Consider to select the proper (de)serializer with appropriate terminator for you: https://docs.spring.io/spring-integration/docs/4.3.12.RELEASE/reference/html/ip.html#connection-factories

StaleObjectStateException : persist failed due to stalestate

I'm stuck here, Couldn't figure out any Solution for StaleObjectStateException.
I have read these StackOverflow Article 1, StackOverflow Article 2, But couldn't get much..
My Code in Abstract Class :
try {
long currentTime = System.currentTimeMillis();
try{
session = sessionFactory.getCurrentSession();
}catch(Exception e){}
if (session == null) {
session = sessionFactory.openSession();
isNewSession = true;
}
if (baseDO.isDeleted()) {
log.debug("Deleting instance" + baseDO.getId());
session.delete(baseDO);
} else if (baseDO.isInserted() || baseDO.isNew()) {
log.debug("Inserting instance");
baseDO.setVersionID(1l);
session.saveOrUpdate(this.getDOName(), baseDO);
} else if (baseDO.isUpdated()) {
log.debug("Updating instance");
//Session session = sessionFactory.getCurrentSession();
baseDO = (B) session.merge(this.getDOName(), baseDO);
session.saveOrUpdate(this.getDOName(), baseDO);
/* I'm getting here exactly on above Line */
// sessionFactory.getCurrentSession().saveOrUpdate(baseDO);
log.debug("Updated instance" + baseDO);
} else {
log.warn("*** Not persisting any Data for " + getDOName() + " ***");
}
log.debug("persist successful");
}
catch(StaleObjectStateException stoe){
log.error("persist failed due to stalestate", stoe);
throw stoe;
}
catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
finally {
if (session != null && isNewSession)
session.close();
}
This is the Error I'm getting :
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) [ERROR] 11:13:52 AbstractDAO - persist failed due to stalestate
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.c2lbiz.symbiosys.insurance.businesscommon.dataobjects.payment.CompensationPayableDO#18238]
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:261)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at com.c2lbiz.symbiosys.systemcommon.dao.hibernate.AbstractDAO.save(AbstractDAO.java:549)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at com.c2lbiz.symbiosys.systemcommon.business.BaseBO.save(BaseBO.java:291)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at com.c2lbiz.symbiosys.interfaces.job.GlPostingWriter.execute(GlPostingWriter.java:63)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at com.c2lbiz.symbiosys.interfaces.job.GlPostingWriter.execute(GlPostingWriter.java:1)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.GeneratedMethodAccessor598.invoke(Unknown Source)
11:13:52,339 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.lang.reflect.Method.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at $Proxy62.execute(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.lang.reflect.Method.invoke(Unknown Source)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator.doInvoke(AbstractMethodInvokingDelegator.java:117)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator.invokeDelegateMethodWithArgument(AbstractMethodInvokingDelegator.java:72)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.item.adapter.ItemWriterAdapter.write(ItemWriterAdapter.java:36)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:171)
11:13:52,354 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:150)
11:13:52,370 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:269)
11:13:52,370 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:194)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:74)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:386)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:250)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
11:13:52,371 INFO [stdout] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#62b093c8-1) at java.lang.Thread.run(Unknown Source)
Please Help,
Thanks in Advance.

Databound treegrid displays all leafs as folders after reparent, although defaultIsFolder is set to false

i use smartgwt 2.5. i have a databound treegrid which fetches a json from the database and builds the tree. this works fine. the problem is when i try to reparent for example
at begin the tree looks like:
my json that is fetched from the db:
[{"id":"a","ReportsTo":"root","isFolder":"true","isOpen":"false"},{"id":"b","ReportsTo":"c","isFolder":"false", "isOpen":"false"},{"id":"c","ReportsTo":"root","isFolder":"true","isOpen":"true"},{"id":"d","ReportsTo":"a","isFolder":"false","isOpen":"false"}]
after reparent b (drag b at folder c and drop it into c) all leafs gets folders:
http://i.stack.imgur.com/lLHdX.png
this is send to the server:
{
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "dataSource":"isc_RestDataSource_0",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "operationType":"update",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "data":{
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "id":"b",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "ReportsTo":"c",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "isFolder":false,
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "isOpen":"false"
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) },
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "oldValues":{
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "id":"b",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "ReportsTo":"a",
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "isFolder":false,
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) "isOpen":"false"
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) }
12:46:52,773 INFO [stdout] (http--127.0.0.1-7443-4) }
after site refresh the tree is displayed correctly:
a
c
-b
-d
my code for the treegrid:
public class FavoritesGrid extends TreeGrid {
public FavoritesGrid() {
setWidth("12%");
setShowConnectors(false);
setShowResizeBar(true);
setCanReorderRecords(true);
setCanAcceptDroppedRecords(true);
setCanDragRecordsOut(true);
setCanReparentNodes(true);
setDragDataAction(DragDataAction.MOVE);
setAutoSaveEdits(false);
setAutoFetchData(false);
setLoadDataOnDemand(false); //load everything
setHeight("50%");
RestDataSource ds = new RestDataSource();
ds.setRecordXPath("/");
ds.setDataFormat(DSDataFormat.JSON);
OperationBinding fetch = new OperationBinding();
fetch.setOperationType(DSOperationType.FETCH);
fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
fetch.setDataFormat(DSDataFormat.JSON);
OperationBinding add = new OperationBinding();
add.setOperationType(DSOperationType.ADD);
add.setDataProtocol(DSProtocol.POSTMESSAGE);
add.setDataFormat(DSDataFormat.JSON);
OperationBinding update = new OperationBinding();
update.setOperationType(DSOperationType.UPDATE);
update.setDataProtocol(DSProtocol.POSTMESSAGE);
update.setDataFormat(DSDataFormat.JSON);
ds.setOperationBindings(fetch, update, add);
ds.setDataURL("/Kronos/Favorites");
DataSourceTextField key = new DataSourceTextField("id", "id");
key.setPrimaryKey(true);
key.setRequired(true);
DataSourceTextField parent = new DataSourceTextField("ReportsTo",
"ReportsTo");
parent.setRequired(true);
parent.setForeignKey("id");
parent.setRootValue("root");
ds.setFields(key, parent);
//define properties
Tree tree = new Tree();
tree.setDefaultIsFolder(false); //default the nodes should be leafs
tree.setRootValue("root");
tree.setNameProperty("id");
tree.setIdField("id");
tree.setParentIdField("ReportsTo");
//the setOpenProperty also doesn't work
//if i set it smartgwt displays all folder opened
tree.setOpenProperty("isOpen");
//setIsFolderProperty is being ignored after reparent, need to refresh the site for correction
tree.setIsFolderProperty("isFolder");
setDataProperties(tree);
setDataSource(ds);
fetchData();
}
}
can somebody pls help me?

Categories