Stateful Retry Advice does not resubmit message - spring-integration
We are using Spring Integration + JMS + ActiveMQ to exchange messages between microservices using Virtual Topics.
Here is our configuration for the inbound messages:
#Autowired
lateinit var connectionFactory: ConnectionFactory
#Autowired
lateinit var messageConverter: MessageConverter
#Bean("file-uploaded.inbound")
fun inboundChannel() = MessageChannels.queue().get()
#Bean("file-uploaded.inbound.flow")
fun inboundFlow(): IntegrationFlow {
return IntegrationFlows.from(
Jms.messageDrivenChannelAdapter(
Jms.container(connectionFactory,
"Consumer.appId.VirtualTopic.file-uploaded")
.pubSubDomain(false).get()
).jmsMessageConverter(messageConverter)
).channel(inboundChannel()).get()
}
and here is our retry advice (fairly default, except for the retry state generator):
#Bean
fun requestHandlerRetryAdvice(): RequestHandlerRetryAdvice {
return RequestHandlerRetryAdvice().apply {
setRetryStateGenerator(SpelExpressionRetryStateGenerator("headers[\"jms_messageId\"]"))
setRecoveryCallback(ErrorMessageSendingRecoverer())
}
}
and message handler:
#MessageEndpoint
class FileUploadedEventListener() {
#ServiceActivator(inputChannel = "file-uploaded.inbound", adviceChain = ["requestHandlerRetryAdvice"])
fun handleFileUploadedEvent(fileUploadedEvent: FileUploadedEvent) {
LoggerFactory.getLogger(this.javaClass.name).info("Received event: $fileUploadedEvent")
throw RuntimeException()
}
}
Basically the reply advice is not putting the message back on the queue as it is supposed to (as per documentation) and it is sending an error message on the 'errorChannel' after the first try.
Has anyone experienced the same problem using Virtual Topics?
Or are we just missing something in the configuration?
Thanks!
Update here below the debug logging:
2018-09-19 15:40:07.877 DEBUG .i.j.ChannelPublishingJmsMessageListener : converted JMS Message [ActiveMQBytesMessage {commandId = 5, responseRequired = true, messageId = ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1, originalDestination = topic://VirtualTopic.file-uploaded, originalTransactionId = null, producerId = ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1, destination = queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, transactionId = null, expiration = 0, timestamp = 1537368007815, arrival = 0, brokerInTime = 1537368007821, brokerOutTime = 1537368007822, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = org.apache.activemq.util.ByteSequence#732fdf26, marshalledProperties = org.apache.activemq.util.ByteSequence#6ca08492, dataStructure = null, redeliveryCounter = 0, size = 0, properties = {spanTraceId=4770babc94e7d760, spanId=0c31247dd4ed71eb, spanParentSpanId=4770babc94e7d760, _type=FileUploadedEvent, spanSampled=0}, readOnlyProperties = true, readOnlyBody = true, droppable = false, jmsXGroupFirstForConsumer = false} ActiveMQBytesMessage{ bytesOut = null, dataOut = null, dataIn = java.io.DataInputStream#33c0baa3 }] to integration Message payload [FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1)]
2018-09-19 15:40:07.879 DEBUG o.s.integration.channel.DirectChannel : preSend on channel 'file-uploaded.inbound.flow.channel#0', message: GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={spanTraceId=4770babc94e7d760, spanId=0c31247dd4ed71eb, spanParentSpanId=4770babc94e7d760, jms_redelivered=false, jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, id=266d356e-dc90-cb33-8818-40a3cf718125, priority=4, spanSampled=0, jms_timestamp=1537368007815, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1, timestamp=1537368007879}]
2018-09-19 15:40:07.882 DEBUG o.s.integration.handler.BridgeHandler : file-uploaded.inbound.flow.org.springframework.integration.handler.BridgeHandler#0 received message: GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, X-B3-ParentSpanId=0c31247dd4ed71eb, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=04c0bd5a812ee159, spanParentSpanId=0c31247dd4ed71eb, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[04c0bd5a812ee159], spanParentSpanId=[0c31247dd4ed71eb], spanSampled=[0]}, jms_redelivered=false, X-B3-SpanId=04c0bd5a812ee159, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=33d89f7b-dbf8-b381-add7-549d875dd914, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1, timestamp=1537368007881}]
2018-09-19 15:40:07.883 DEBUG o.s.integration.channel.QueueChannel : preSend on channel 'file-uploaded.inbound', message: GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, X-B3-ParentSpanId=0c31247dd4ed71eb, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=04c0bd5a812ee159, spanParentSpanId=0c31247dd4ed71eb, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[04c0bd5a812ee159], spanParentSpanId=[0c31247dd4ed71eb], spanSampled=[0]}, jms_redelivered=false, X-B3-SpanId=04c0bd5a812ee159, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=33d89f7b-dbf8-b381-add7-549d875dd914, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1, timestamp=1537368007881}]
2018-09-19 15:40:07.884 DEBUG o.s.integration.channel.QueueChannel : postSend (sent=true) on channel 'file-uploaded.inbound', message: GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, X-B3-ParentSpanId=04c0bd5a812ee159, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=49b4d98b393a623e, spanParentSpanId=04c0bd5a812ee159, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[49b4d98b393a623e], spanParentSpanId=[04c0bd5a812ee159], spanSampled=[0], X-B3-TraceId=[4770babc94e7d760], X-B3-SpanId=[49b4d98b393a623e], X-B3-ParentSpanId=[04c0bd5a812ee159], X-B3-Sampled=[0]}, jms_redelivered=false, X-B3-SpanId=49b4d98b393a623e, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=70e86708-b383-ce4a-61f5-36a69ecadfeb, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1, timestamp=1537368007883}]
2018-09-19 15:40:07.884 DEBUG o.s.integration.channel.QueueChannel : postReceive on channel 'file-uploaded.inbound', message: GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, X-B3-ParentSpanId=04c0bd5a812ee159, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=49b4d98b393a623e, spanParentSpanId=04c0bd5a812ee159, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[49b4d98b393a623e], spanParentSpanId=[04c0bd5a812ee159], spanSampled=[0], X-B3-TraceId=[4770babc94e7d760], X-B3-SpanId=[49b4d98b393a623e], X-B3-ParentSpanId=[04c0bd5a812ee159], X-B3-Sampled=[0]}, jms_redelivered=false, X-B3-SpanId=49b4d98b393a623e, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=70e86708-b383-ce4a-61f5-36a69ecadfeb, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1, timestamp=1537368007883}]
2018-09-19 15:40:07.884 DEBUG o.s.i.handler.ServiceActivatingHandler : ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor#62a15309] (fileUploadedEventListener.handleFileUploadedEvent.serviceActivator.handler) received message: GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=7f9b16d7f7d5b347, spanParentSpanId=49b4d98b393a623e, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[7f9b16d7f7d5b347], spanParentSpanId=[49b4d98b393a623e], spanSampled=[0]}, jms_redelivered=false, id=4c6d131e-448e-9863-f84b-7a4a8e563b09, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1}]
2018-09-19 15:40:07.884 DEBUG o.s.integration.channel.DirectChannel : postSend (sent=true) on channel 'file-uploaded.inbound.flow.channel#0', message: GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, X-B3-ParentSpanId=0c31247dd4ed71eb, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=04c0bd5a812ee159, spanParentSpanId=0c31247dd4ed71eb, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[7f9b16d7f7d5b347], spanParentSpanId=[49b4d98b393a623e], spanSampled=[0]}, jms_redelivered=false, X-B3-SpanId=04c0bd5a812ee159, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=33d89f7b-dbf8-b381-add7-549d875dd914, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1, timestamp=1537368007881}]
2018-09-19 15:40:07.888 DEBUG o.s.retry.support.RetryTemplate : Retry: count=0
2018-09-19 15:40:07.901 INFO c.b.p.a.a.e.FileUploadedEventListener : Received file uploaded event GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=7f9b16d7f7d5b347, spanParentSpanId=49b4d98b393a623e, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[7f9b16d7f7d5b347], spanParentSpanId=[49b4d98b393a623e], spanSampled=[0]}, jms_redelivered=false, id=4c6d131e-448e-9863-f84b-7a4a8e563b09, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1}]
2018-09-19 15:40:07.902 DEBUG o.s.retry.support.RetryTemplate : Checking for rethrow: count=1
2018-09-19 15:40:07.902 DEBUG o.s.retry.support.RetryTemplate : Rethrow in retry for policy: count=1
2018-09-19 15:40:07.904 DEBUG o.s.i.channel.PublishSubscribeChannel : preSend on channel 'errorChannel', message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: nested exception is java.lang.RuntimeException, failedMessage=GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=7f9b16d7f7d5b347, spanParentSpanId=49b4d98b393a623e, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[7f9b16d7f7d5b347], spanParentSpanId=[49b4d98b393a623e], spanSampled=[0]}, jms_redelivered=false, id=4c6d131e-448e-9863-f84b-7a4a8e563b09, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1}], headers={id=631dd6f9-0e84-15c7-c953-48d732c25270, timestamp=1537368007904}] for original GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, X-B3-ParentSpanId=49b4d98b393a623e, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=7f9b16d7f7d5b347, spanParentSpanId=49b4d98b393a623e, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[7f9b16d7f7d5b347], spanParentSpanId=[49b4d98b393a623e], spanSampled=[0]}, jms_redelivered=false, X-B3-SpanId=7f9b16d7f7d5b347, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=88313bfb-a45d-c9ff-268f-5c2f50e03156, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1}]
2018-09-19 15:40:07.904 DEBUG o.s.i.handler.ServiceActivatingHandler : ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor#484a98b8] (fileUploadedEventListener.handleError.serviceActivator.handler) received message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: nested exception is java.lang.RuntimeException, failedMessage=GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=7f9b16d7f7d5b347, spanParentSpanId=49b4d98b393a623e, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[b72c67f61de7c366], spanParentSpanId=[7f9b16d7f7d5b347], spanSampled=[0], X-B3-TraceId=[4770babc94e7d760], X-B3-SpanId=[b72c67f61de7c366], X-B3-ParentSpanId=[7f9b16d7f7d5b347], X-B3-Sampled=[0]}, jms_redelivered=false, id=4c6d131e-448e-9863-f84b-7a4a8e563b09, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1}], headers={X-B3-ParentSpanId=7f9b16d7f7d5b347, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=69a058ce-deed-f3e2-eb20-d4e874171ba6, X-B3-SpanId=b72c67f61de7c366, timestamp=1537368007904}]
2018-09-19 15:40:07.905 DEBUG o.s.i.handler.ServiceActivatingHandler : handler 'ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor#484a98b8] (fileUploadedEventListener.handleError.serviceActivator.handler)' produced no reply for request Message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: nested exception is java.lang.RuntimeException, failedMessage=GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=7f9b16d7f7d5b347, spanParentSpanId=49b4d98b393a623e, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[b72c67f61de7c366], spanParentSpanId=[7f9b16d7f7d5b347], spanSampled=[0], X-B3-TraceId=[4770babc94e7d760], X-B3-SpanId=[b72c67f61de7c366], X-B3-ParentSpanId=[7f9b16d7f7d5b347], X-B3-Sampled=[0]}, jms_redelivered=false, id=4c6d131e-448e-9863-f84b-7a4a8e563b09, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1}], headers={X-B3-ParentSpanId=7f9b16d7f7d5b347, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=69a058ce-deed-f3e2-eb20-d4e874171ba6, X-B3-SpanId=b72c67f61de7c366, timestamp=1537368007904}]
2018-09-19 15:40:07.905 DEBUG o.s.integration.handler.LoggingHandler : _org.springframework.integration.errorLogger.handler received message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: nested exception is java.lang.RuntimeException, failedMessage=GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=7f9b16d7f7d5b347, spanParentSpanId=49b4d98b393a623e, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[b72c67f61de7c366], spanParentSpanId=[7f9b16d7f7d5b347], spanSampled=[0], X-B3-TraceId=[4770babc94e7d760], X-B3-SpanId=[b72c67f61de7c366], X-B3-ParentSpanId=[7f9b16d7f7d5b347], X-B3-Sampled=[0]}, jms_redelivered=false, id=4c6d131e-448e-9863-f84b-7a4a8e563b09, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1}], headers={X-B3-ParentSpanId=7f9b16d7f7d5b347, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=69a058ce-deed-f3e2-eb20-d4e874171ba6, X-B3-SpanId=b72c67f61de7c366, timestamp=1537368007904}]
2018-09-19 15:40:07.906 ERROR o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessageHandlingException: nested exception is java.lang.RuntimeException, failedMessage=GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=7f9b16d7f7d5b347, spanParentSpanId=49b4d98b393a623e, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[b72c67f61de7c366], spanParentSpanId=[7f9b16d7f7d5b347], spanSampled=[0], X-B3-TraceId=[4770babc94e7d760], X-B3-SpanId=[b72c67f61de7c366], X-B3-ParentSpanId=[7f9b16d7f7d5b347], X-B3-Sampled=[0]}, jms_redelivered=false, id=4c6d131e-448e-9863-f84b-7a4a8e563b09, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1}]
at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:107)
at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:93)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler$AdvisedRequestHandler.handleRequestMessage(AbstractReplyProducingMessageHandler.java:182)
[...]
Caused by: java.lang.RuntimeException
at FileUploadedEventListener.handleFileUploadedEvent(FileUploadedEventListener.kt:35)
at FileUploadedEventListener$$FastClassBySpringCGLIB$$eb75a593.invoke(<generated>)
[...]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:181)
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:114)
at org.springframework.integration.util.MessagingMethodInvokerHelper$HandlerMethod.invoke(MessagingMethodInvokerHelper.java:1056)
at org.springframework.integration.util.MessagingMethodInvokerHelper.invokeHandlerMethod(MessagingMethodInvokerHelper.java:574)
at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:468)
at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:312)
at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:104)
... 29 more
2018-09-19 15:40:07.907 DEBUG o.s.i.channel.PublishSubscribeChannel : postSend (sent=true) on channel 'errorChannel', message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: nested exception is java.lang.RuntimeException, failedMessage=GenericMessage [payload=FileUploadedEvent(assetId=c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, objectKey=account-id/c9c73263-e05c-4cb0-bf7b-ea2d3b934c13, bucketName=platform-asset-storage-dev, accountId=account-id, fileName=unknown, userId=1), headers={jms_destination=queue://Consumer.dev-platform-asset-previews.VirtualTopic.file-uploaded, _type=FileUploadedEvent, priority=4, jms_timestamp=1537368007815, spanTraceId=4770babc94e7d760, spanId=7f9b16d7f7d5b347, spanParentSpanId=49b4d98b393a623e, nativeHeaders={spanTraceId=[4770babc94e7d760], spanId=[b72c67f61de7c366], spanParentSpanId=[7f9b16d7f7d5b347], spanSampled=[0], X-B3-TraceId=[4770babc94e7d760], X-B3-SpanId=[b72c67f61de7c366], X-B3-ParentSpanId=[7f9b16d7f7d5b347], X-B3-Sampled=[0]}, jms_redelivered=false, id=4c6d131e-448e-9863-f84b-7a4a8e563b09, spanSampled=0, jms_messageId=ID:Marcos-MBP.intranet-57777-1537280015474-1:71:1:1:1}], headers={X-B3-ParentSpanId=7f9b16d7f7d5b347, X-B3-Sampled=0, X-B3-TraceId=4770babc94e7d760, id=69a058ce-deed-f3e2-eb20-d4e874171ba6, X-B3-SpanId=b72c67f61de7c366, timestamp=1537368007904}]
fun inboundChannel() = MessageChannels.queue().get()
It's because you are using a QueueChannel - you need DirectChannel if you want the exception to be thrown back to inbound channel adapter so the message will be requeued.
With a queue channel, the poller will simply send the exception to the error channel.
Related
print or output the selected residues in pymol
I am following this step to print the residues that I selected in pymol, and I found that some of the residues got iterated more than 1 time. Does anyone know what the problem is? ls = [] iterate selected, ls.append((resi, resn)) print ls The selected residues are 29 amino acids in total, and here is the result of the output. [('1', 'MET'), ('2', 'PHE'), ('3', 'ILE'), ('4', 'PHE'), ('5', 'LEU'), ('6', 'LEU'), ('7', 'PHE'), ('8', 'LEU'), ('9', 'THR'), ('10', 'LEU'), ('11', 'THR'), ('12', 'SER'), ('13', 'GLY'), ('14', 'SER'), ('15', 'ASP'), ('16', 'LEU'), ('17', 'ASP'), ('18', 'ARG'), ('18', 'ARG'), ('18', 'ARG'), ('18', 'ARG'), ('18', 'ARG'), ('18', 'ARG'), ('18', 'ARG'), ('18', 'ARG'), ('18', 'ARG'), ('18', 'ARG'), ('18', 'ARG'), ('19', 'CYS'), ('19', 'CYS'), ('19', 'CYS'), ('19', 'CYS'), ('19', 'CYS'), ('19', 'CYS'), ('20', 'THR'), ('20', 'THR'), ('20', 'THR'), ('20', 'THR'), ('20', 'THR'), ('20', 'THR'), ('20', 'THR'), ('21', 'THR'), ('21', 'THR'), ('21', 'THR'), ('21', 'THR'), ('21', 'THR'), ('21', 'THR'), ('21', 'THR'), ('22', 'PHE'), ('22', 'PHE'), ('22', 'PHE'), ('22', 'PHE'), ('22', 'PHE'), ('22', 'PHE'), ('22', 'PHE'), ('22', 'PHE'), ('22', 'PHE'), ('22', 'PHE'), ('22', 'PHE'), ('23', 'ASP'), ('23', 'ASP'), ('23', 'ASP'), ('23', 'ASP'), ('23', 'ASP'), ('23', 'ASP'), ('23', 'ASP'), ('23', 'ASP'), ('24', 'ASP'), ('24' , 'ASP'), ('24', 'ASP'), ('24', 'ASP'), ('24', 'ASP'), ('24', 'ASP'), ('24', 'ASP'), ('24', 'ASP'), ('25', 'VAL'), ('25', 'VAL'), ('25', 'VAL'), ('25', 'VAL'), ('25', 'VAL'), ('25', 'VAL'), ('25', 'VAL'), ('26', 'GLN'), ('26', 'GLN'), ('26', 'GLN'), ('26', 'GLN'), ('26', 'GLN'), ('26', 'GLN'), ('26', 'GLN'), ('26', 'GLN'), ('26', 'GLN'), ('27', 'ALA'), ('27', 'ALA'), ('27', 'ALA'), ('27', 'ALA'), ('27', 'ALA'), ('28', 'PRO'), ('28', 'PRO'), ('28', 'PRO'), ('28', 'PRO'), ('28', 'PRO'), ('28', 'PRO'), ('28', 'PRO'), ('29', 'ASN'), ('29', 'ASN'), ('29', 'ASN'), ('29', 'ASN'), ('29', 'ASN'), ('29', 'ASN'), ('29', 'ASN'), ('29', 'ASN')]
Pymol iterates over every atom. Restrict search to one atom per residue like this: iterate selected and name CA, ls.append((resi, resn)) Or, better yet, have the whole seqeunce in one line like this: iterate selected and name CA, print (resi, resn)
How can'i download a PDF file from iframe in internet explorer 8
I would to download a PDF file from iframe it worked in Google chrome and firefox but it not worked in Internet explorer. This is my code public void downloadSubscriptionDocument(SessionObject object) { Document dt = getBlobCode(object); if (dt != null && dt.getData() != null) { final FacesContext fContext = FacesContext.getCurrentInstance(); ExternalContext eContext = null; if (fContext != null && dt != null) { eContext = fContext.getExternalContext(); if (eContext != null) { final HttpServletResponse response = (HttpServletResponse) eContext.getResponse(); response.setContentType("application/pdf"); response.addHeader("content-disposition", "attachment; filename=" + "BulletinAdhesion" + ".pdf"); if (dt != null && dt.getData() != null) { response.addHeader("Content-Length", String.valueOf(dt.getData().length)); } try { final ServletOutputStream sos = response.getOutputStream(); sos.write(dt.getData()); sos.flush(); sos.close(); fContext.responseComplete(); } catch (final Exception ex) { LOGGER.log(Level.SEVERE, ex.getMessage()); } } } } else { Locale locale = new Locale("fr"); this.addMessageError(ResourceBundle.getBundle("messages", locale).getString("eu.spb.afflelou.pdv.ba.not.found")); return ; } } I have this exception in console Servlet] - 2019-12-04 10:30:29,289 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spb-extranet-afflelou-pdv].[Faces Servlet]] (ajp-/10.7.2.55 {s2jbossrecex.spb.eu} :8809-3) JBWEB000236: Servlet.service() for servlet Faces Servlet threw exception: java.lang.IllegalStateException: JBWEB000028: getOutputStream() has already been called for this response at org.apache.catalina.connector.Response.getWriter(Response.java:621) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:191) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at com.sun.faces.context.ExternalContextImpl.getResponseOutputWriter(ExternalContextImpl.java:778) [jsf-impl-2.1.28.SP11-redhat-1.jar:2.1.28.SP11-redhat-1] at javax.faces.context.ExternalContextWrapper.getResponseOutputWriter(ExternalContextWrapper.java:669) [jboss-jsf-api_2.1_spec-2.1.28.SP2-redhat-1.jar:2.1.28.SP2-redhat-1] at com.sun.faces.application.view.FaceletViewHandlingStrategy.createResponseWriter(FaceletViewHandlingStrategy.java:1110) [jsf-impl-2.1.28.SP11-redhat-1.jar:2.1.28.SP11-redhat-1] at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399) [jsf-impl-2.1.28.SP11-redhat-1.jar:2.1.28.SP11-redhat-1] at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125) [jsf-impl-2.1.28.SP11-redhat-1.jar:2.1.28.SP11-redhat-1] at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286) [jboss-jsf-api_2.1_spec-2.1.28.SP2-redhat-1.jar:2.1.28.SP2-redhat-1] at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286) [jboss-jsf-api_2.1_spec-2.1.28.SP2-redhat-1.jar:2.1.28.SP2-redhat-1] at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286) [jboss-jsf-api_2.1_spec-2.1.28.SP2-redhat-1.jar:2.1.28.SP2-redhat-1] at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) [jsf-impl-2.1.28.SP11-redhat-1.jar:2.1.28.SP11-redhat-1] at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.28.SP11-redhat-1.jar:2.1.28.SP11-redhat-1] at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.28.SP11-redhat-1.jar:2.1.28.SP11-redhat-1] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.1.28.SP2-redhat-1.jar:2.1.28.SP2-redhat-1] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.event(JBossWebContext.java:91) at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.invoke(JBossWebContext.java:72) at org.jboss.as.web.security.SubjectInfoSetupValve.invoke(SubjectInfoSetupValve.java:34) [jboss-as-web-7.5.22.Final-redhat-1.jar:7.5.22.Final-redhat-1] at org.jboss.as.web.session.ClusteredSessionValve.handleRequest(ClusteredSessionValve.java:134) [jboss-as-web-7.5.22.Final-redhat-1.jar:7.5.22.Final-redhat-1] at org.jboss.as.web.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:99) [jboss-as-web-7.5.22.Final-redhat-1.jar:7.5.22.Final-redhat-1] at org.jboss.as.web.session.JvmRouteValve.invoke(JvmRouteValve.java:95) [jboss-as-web-7.5.22.Final-redhat-1.jar:7.5.22.Final-redhat-1] at org.jboss.as.web.session.LockingValve.invoke(LockingValve.java:64) [jboss-as-web-7.5.22.Final-redhat-1.jar:7.5.22.Final-redhat-1] at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.5.22.Final-redhat-1.jar:7.5.22.Final-redhat-1] at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.5.22.Final-redhat-1.jar:7.5.22.Final-redhat-1] at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.5.22.Final-redhat-1.jar:7.5.22.Final-redhat-1] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:490) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:422) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.5.30.Final-redhat-1.jar:7.5.30.Final-redhat-1]
how can I prevent an Error on the delete rule deny in Core Data, Swift 3
how can I prevent an Error on the delete rule deny? I have a Alert that ask the user for deletion a record, but the check if it can be deleted happens first in the save method in core data stack. I trieb to catch it with: if (self?.categoryToEdit.toMyplace == nil){ let alertController = UIAlertController(title: "Kategorie löschen", message: "Die Kategorie " + categoryName + " kann nicht gelöscht werden!\r\nSie ist ", preferredStyle: .actionSheet) let cancelButton = UIAlertAction(title: "Abbrechen", style: .cancel, handler: { [weak self](action) -> Void in self?.tableView.setEditing(false, animated: true) self?.attemptFetch() self?.tableView.reloadData() return }) alertController.addAction(cancelButton) self?.present(alertController, animated: false, completion: nil) }else{ self?.displayActionSheet(indexPath: indexPath as NSIndexPath) } so I get an error from compiler: fatal error: unexpectedly found nil while unwrapping an Optional value how can I solve it? Thanks in advance!!!! EDIT Thank you! Here the complete code. It starts in the tableView action and is forwarded to separate function where the alerts are handled. The uncommented parts in this functions are not really working. I get first an alert when it handles the error. It wouldn't be a huge Problem if the record didn't vanish from the tableView and left incense in the index of the working array. This problem remains till the App will be restarted there are noch chance to get the not deleted record. I try new fetch requests and reloaded the table date but it stays away till new start. func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { let edit = UITableViewRowAction(style: .normal, title: "Ändern") { [weak self] action, index in self?.editMode = true let cell = tableView.cellForRow(at: indexPath) as! CategoryTVCell self?.configureCell(cell: cell, indexPath: indexPath) context.performAndWait{ if let obj = self?.controller.fetchedObjects , obj.count > 0 { self?.categoryToEdit = obj[indexPath.row] self?.categoryToEditName = self?.categoryToEdit.name! } } self?.showAlertWithText() self?.showAlertWithText() tableView.isEditing = false } let delete = UITableViewRowAction(style: .normal, title: "Löschen") { [weak self] action, index in self?.displayActionSheet(indexPath: indexPath as NSIndexPath) } edit.backgroundColor = UIColor(colorLiteralRed: 179.0/255.0, green: 179.0/255.0, blue: 179.0/255.0, alpha: 1) delete.backgroundColor = myRedAlertColor return [delete, edit] } private func displayActionSheet(indexPath: NSIndexPath) { let categoryName = categoryArray[indexPath.row] let alertController = UIAlertController(title: "Kategorie löschen", message: "Soll die Kategorie " + categoryName + " gelöscht werden?\r\nDie Kategorie kann nur gelöscht werden, wenn kein myPlace damit verbunden ist!", preferredStyle: .actionSheet) let deleteCategory = UIAlertAction(title: "Löschen", style: .destructive, handler: { [weak self](action) -> Void in self?.tableView.isEditing = false //if (self?.categoryToEdit.toMyplace == nil)/*((self?.myPlace?.toCateogry == nil))*/{ context.delete((self?.controller.fetchedObjects?[indexPath.row])!) self?.categoryArray.remove(at: indexPath.row) self?.attemptFetch() self?.tableView.reloadData() //}else{ /*let alertController = UIAlertController(title: "Kategorie löschen", message: "Die Kategorie " + categoryName + " kann nicht gelöscht werden!\r\nSie ist ", preferredStyle: .actionSheet) let cancelButton = UIAlertAction(title: "Abbrechen", style: .cancel, handler: { [weak self](action) -> Void in self?.tableView.setEditing(false, animated: true) self?.attemptFetch() self?.tableView.reloadData() }) alertController.addAction(cancelButton) self?.present(alertController, animated: false, completion: nil)*/ //} do{ try context.save() }catch{ let alertController = UIAlertController(title: "Kategorie löschen", message: "Die Kategorie " + categoryName + " kann nicht gelöscht werden!\r\nAlle myPlaces verlieren sonst diese Zuordnung!", preferredStyle: .actionSheet) let cancelButton = UIAlertAction(title: "Abbrechen", style: .cancel, handler: { [weak self](action) -> Void in self?.tableView.setEditing(false, animated: true) self?.attemptFetch() self?.tableView.reloadData() }) alertController.addAction(cancelButton) self?.present(alertController, animated: false, completion: nil) } }) let cancelButton = UIAlertAction(title: "Abbrechen", style: .cancel, handler: { [weak self](action) -> Void in self?.tableView.setEditing(false, animated: true) }) alertController.addAction(deleteCategory) alertController.addAction(cancelButton) alertController.view.tintColor = .orange //UIColor(red: 0, green: 0, blue: 51) //self.navigationController!.present(alertController, animated: true, completion: nil) present(alertController, animated: false, completion: nil) }
Thank you! Here the complete code. It starts in the tableView action and is forwarded to separate function where the alerts are handled. The uncommented parts in this functions are not really working. I get first an alert when it handles the error. It wouldn't be a huge Problem if the record didn't vanish from the tableView and left incense in the index of the working array. This problem remains till the App will be restarted there are noch chance to get the not deleted record. I try new fetch requests and reloaded the table date but it stays away till new start. func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { let edit = UITableViewRowAction(style: .normal, title: "Ändern") { [weak self] action, index in self?.editMode = true let cell = tableView.cellForRow(at: indexPath) as! CategoryTVCell self?.configureCell(cell: cell, indexPath: indexPath) context.performAndWait{ if let obj = self?.controller.fetchedObjects , obj.count > 0 { self?.categoryToEdit = obj[indexPath.row] self?.categoryToEditName = self?.categoryToEdit.name! } } self?.showAlertWithText() self?.showAlertWithText() tableView.isEditing = false } let delete = UITableViewRowAction(style: .normal, title: "Löschen") { [weak self] action, index in self?.displayActionSheet(indexPath: indexPath as NSIndexPath) } edit.backgroundColor = UIColor(colorLiteralRed: 179.0/255.0, green: 179.0/255.0, blue: 179.0/255.0, alpha: 1) delete.backgroundColor = myRedAlertColor return [delete, edit] } private func displayActionSheet(indexPath: NSIndexPath) { let categoryName = categoryArray[indexPath.row] let alertController = UIAlertController(title: "Kategorie löschen", message: "Soll die Kategorie " + categoryName + " gelöscht werden?\r\nDie Kategorie kann nur gelöscht werden, wenn kein myPlace damit verbunden ist!", preferredStyle: .actionSheet) let deleteCategory = UIAlertAction(title: "Löschen", style: .destructive, handler: { [weak self](action) -> Void in self?.tableView.isEditing = false //if (self?.categoryToEdit.toMyplace == nil)/*((self?.myPlace?.toCateogry == nil))*/{ context.delete((self?.controller.fetchedObjects?[indexPath.row])!) self?.categoryArray.remove(at: indexPath.row) self?.attemptFetch() self?.tableView.reloadData() //}else{ /*let alertController = UIAlertController(title: "Kategorie löschen", message: "Die Kategorie " + categoryName + " kann nicht gelöscht werden!\r\nSie ist ", preferredStyle: .actionSheet) let cancelButton = UIAlertAction(title: "Abbrechen", style: .cancel, handler: { [weak self](action) -> Void in self?.tableView.setEditing(false, animated: true) self?.attemptFetch() self?.tableView.reloadData() }) alertController.addAction(cancelButton) self?.present(alertController, animated: false, completion: nil)*/ //} do{ try context.save() }catch{ let alertController = UIAlertController(title: "Kategorie löschen", message: "Die Kategorie " + categoryName + " kann nicht gelöscht werden!\r\nAlle myPlaces verlieren sonst diese Zuordnung!", preferredStyle: .actionSheet) let cancelButton = UIAlertAction(title: "Abbrechen", style: .cancel, handler: { [weak self](action) -> Void in self?.tableView.setEditing(false, animated: true) self?.attemptFetch() self?.tableView.reloadData() }) alertController.addAction(cancelButton) self?.present(alertController, animated: false, completion: nil) } }) let cancelButton = UIAlertAction(title: "Abbrechen", style: .cancel, handler: { [weak self](action) -> Void in self?.tableView.setEditing(false, animated: true) }) alertController.addAction(deleteCategory) alertController.addAction(cancelButton) alertController.view.tintColor = .orange //UIColor(red: 0, green: 0, blue: 51) //self.navigationController!.present(alertController, animated: true, completion: nil) present(alertController, animated: false, completion: nil) }
Here the solution: let delete = UITableViewRowAction(style: .normal, title: "Löschen") { [weak self] action, index in do{ try self?.controller.fetchedObjects?[indexPath.row].validateForDelete() self?.displayActionSheet(indexPath: indexPath as NSIndexPath) }catch{ let categoryName = self?.categoryArray[indexPath.row] let alertController = UIAlertController(title: "Kategorie löschen", message: "Die Kategorie " + categoryName! + " kann nicht gelöscht werden!\r\nSie wird bereits verwendet!", preferredStyle: .actionSheet) let cancelButton = UIAlertAction(title: "Abbrechen", style: .cancel, handler: { [weak self](action) -> Void in self?.tableView.setEditing(false, animated: true) self?.attemptFetch() self?.tableView.reloadData() }) alertController.addAction(cancelButton) self?.present(alertController, animated: false, completion: nil) } } It was simply the function .validateForDelete()
alert(confirm('ok?')) can't work fine in WKWebview
error: Warning: Attempt to present on which is already presenting it seems the alert(confirm('ok?')); style code trigger presenting a view controller simultaneously in WKWebview's delegate, is there any way to support this? my html: <button onclick="alert(1);">alert</button><br> <button onclick="alert(confirm('ok?'));">confirm</button><br> <button onclick="alert(prompt('please input'));">text</button><br> my code: - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler{ NSLog(#"runJavaScriptAlertPanelWithMessage:%#", message); UIAlertController *alert = [UIAlertController alertControllerWithTitle:#"TITLE" message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action = [UIAlertAction actionWithTitle:#"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSLog(#"runJavaScriptAlertPanelWithMessage:%#, did clicked", message); }]; [alert addAction:action]; completionHandler(); [self presentViewController:alert animated:YES completion:nil]; } - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler{ NSLog(#"runJavaScriptAlertPanelWithMessage:%#", message); UIAlertController *alert = [UIAlertController alertControllerWithTitle:#"TITLE" message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action = [UIAlertAction actionWithTitle:#"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSLog(#"runJavaScriptConfirmPanelWithMessage:%#, did clicked yes", message); }]; UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:#"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { NSLog(#"runJavaScriptConfirmPanelWithMessage:%#, did click cancel", message); }]; [alert addAction:action]; [alert addAction:actionCancel]; completionHandler(YES); [self presentViewController:alert animated:YES completion:nil]; }
sorry, my bad. you should use completionHandler in every action callback, not just put it in delegate body, so it could be this: - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler{ NSLog(#"runJavaScriptAlertPanelWithMessage:%#", message); UIAlertController *alert = [UIAlertController alertControllerWithTitle:#"提示" message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action = [UIAlertAction actionWithTitle:#"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSLog(#"runJavaScriptConfirmPanelWithMessage:%#, did clicked", message); completionHandler(YES); }]; UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:#"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { NSLog(#"runJavaScriptConfirmPanelWithMessage:%#, did click cancel", message); completionHandler(NO); }]; [alert addAction:action]; [alert addAction:actionCancel]; [self presentViewController:alert animated:YES completion:nil]; }
Core Data returns null for columns
Core Data returns null for column name. It's my code in viewcontroller for (TaskyEntity *task in [mycoredata searchAllData]) { NSLog(#"title: %#",task.title); NSLog(#"i:%i ",i); i++; } and it's output: 2013-03-17 19:31:08.462 tasky[2623:c07] title: (null) 2013-03-17 19:31:08.463 tasky[2623:c07] i:1 2013-03-17 19:31:08.464 tasky[2623:c07] title: (null) 2013-03-17 19:31:08.464 tasky[2623:c07] i:2 2013-03-17 19:31:08.465 tasky[2623:c07] title: (null) 2013-03-17 19:31:08.466 tasky[2623:c07] i:3 TaskEntity class: -(NSArray *)searchAllData { NSFetchRequest *request = [[NSFetchRequest alloc]init]; [request setEntity:entitydescription]; NSError * error=nil; NSArray *matchData = [context executeFetchRequest:request error:&error]; return matchData; }
Since the loop ran three times, the fetch must have returned three objects. Based on your code, the title attribute is null, and that's why you're getting that result. It's not clear where (or if) you're trying to set this attribute, but your results indicate that it's unset.