File rollback when unable to delete file from smb
I have a Camel route where the producer is an smb mount, and the consumer is an ActiveMQ queue.
I would like to rollback the transaction when SMB server is unable to delete the file from source SMB mount. This, however, happens during commit phase of the transaction.
I can intercept the exception when using onCompletionExceptionHandler, but the catching happens AFTER the Exchange object connected with the file is already sent to the target ActiveMQ.
Is there a way to prevent Camel from commiting the transaction in the first place or rolling back the transaction so that the message isn't sent to AMQ? This behaviour is present in Camel 2.17.2
apache-camel activemq
add a comment |
I have a Camel route where the producer is an smb mount, and the consumer is an ActiveMQ queue.
I would like to rollback the transaction when SMB server is unable to delete the file from source SMB mount. This, however, happens during commit phase of the transaction.
I can intercept the exception when using onCompletionExceptionHandler, but the catching happens AFTER the Exchange object connected with the file is already sent to the target ActiveMQ.
Is there a way to prevent Camel from commiting the transaction in the first place or rolling back the transaction so that the message isn't sent to AMQ? This behaviour is present in Camel 2.17.2
apache-camel activemq
add a comment |
I have a Camel route where the producer is an smb mount, and the consumer is an ActiveMQ queue.
I would like to rollback the transaction when SMB server is unable to delete the file from source SMB mount. This, however, happens during commit phase of the transaction.
I can intercept the exception when using onCompletionExceptionHandler, but the catching happens AFTER the Exchange object connected with the file is already sent to the target ActiveMQ.
Is there a way to prevent Camel from commiting the transaction in the first place or rolling back the transaction so that the message isn't sent to AMQ? This behaviour is present in Camel 2.17.2
apache-camel activemq
I have a Camel route where the producer is an smb mount, and the consumer is an ActiveMQ queue.
I would like to rollback the transaction when SMB server is unable to delete the file from source SMB mount. This, however, happens during commit phase of the transaction.
I can intercept the exception when using onCompletionExceptionHandler, but the catching happens AFTER the Exchange object connected with the file is already sent to the target ActiveMQ.
Is there a way to prevent Camel from commiting the transaction in the first place or rolling back the transaction so that the message isn't sent to AMQ? This behaviour is present in Camel 2.17.2
apache-camel activemq
apache-camel activemq
edited Nov 15 '18 at 13:19
MajkelS
asked Nov 15 '18 at 13:09
MajkelSMajkelS
62
62
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Let's look into the different delivery patterns for messaging:
At least once - the message is deleted from source after it's delivered to target. Same message can be sent multiple times.
- This is what you got now.
At most once - the message is deleted from source before it's delivered to target. Data can be lost.
- Likely not what you want.
Exactly once - message will be deleted from source at the same time it's delivered to target.
- The holy grail. Very hard to achieve.
Ok, so you essentially want a Exactly once semantics. That can "only" be achieved when moving data between queues in the same broker, between tables in a database or by moving a file on a local disk (or internally in the same "resource").
When you have multiple protocols/resources, it's almost impossible, or at least very hard. There are some ways to somewhat ensure exactly once delivery using "two phase commit" transactions using a distributed transaction coordinator, such as MSDTC in Windows or Atomikos in Java (among others). Those will only support transactional resources, such as queues and databases, not file systems such as SMB.
Another way is to use the sagas-pattern. That pattern is maybe a bit overkill in this case though.
So what to do? Well - I can think of at least one way:
Idempotent consumer pattern. This makes Camel hold copies of each message (or a key at least, such as filename) in memory to ensure no single message will be delivered more that once.
// Something like this
from("smb://someplace?&idempotentKey=${file:name}&idempotent=true")
. // Whatnot
.to("activemq:queue:foobar");
Please note that you can configure an idempotent repository to keep entries in database, disk or multiple other places if you want something more persistent (but also more complex).
Hi Petter I need to configure a project using react, PWA and Link-state apollo Can please you guide to some tutorial So that I can configure it at the best level.
– Profer
Jan 4 at 14:03
@Profer I guess that is best done as another question with relevant tags
– Petter Nordlander
Jan 4 at 14:20
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320231%2ffile-rollback-when-unable-to-delete-file-from-smb%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Let's look into the different delivery patterns for messaging:
At least once - the message is deleted from source after it's delivered to target. Same message can be sent multiple times.
- This is what you got now.
At most once - the message is deleted from source before it's delivered to target. Data can be lost.
- Likely not what you want.
Exactly once - message will be deleted from source at the same time it's delivered to target.
- The holy grail. Very hard to achieve.
Ok, so you essentially want a Exactly once semantics. That can "only" be achieved when moving data between queues in the same broker, between tables in a database or by moving a file on a local disk (or internally in the same "resource").
When you have multiple protocols/resources, it's almost impossible, or at least very hard. There are some ways to somewhat ensure exactly once delivery using "two phase commit" transactions using a distributed transaction coordinator, such as MSDTC in Windows or Atomikos in Java (among others). Those will only support transactional resources, such as queues and databases, not file systems such as SMB.
Another way is to use the sagas-pattern. That pattern is maybe a bit overkill in this case though.
So what to do? Well - I can think of at least one way:
Idempotent consumer pattern. This makes Camel hold copies of each message (or a key at least, such as filename) in memory to ensure no single message will be delivered more that once.
// Something like this
from("smb://someplace?&idempotentKey=${file:name}&idempotent=true")
. // Whatnot
.to("activemq:queue:foobar");
Please note that you can configure an idempotent repository to keep entries in database, disk or multiple other places if you want something more persistent (but also more complex).
Hi Petter I need to configure a project using react, PWA and Link-state apollo Can please you guide to some tutorial So that I can configure it at the best level.
– Profer
Jan 4 at 14:03
@Profer I guess that is best done as another question with relevant tags
– Petter Nordlander
Jan 4 at 14:20
add a comment |
Let's look into the different delivery patterns for messaging:
At least once - the message is deleted from source after it's delivered to target. Same message can be sent multiple times.
- This is what you got now.
At most once - the message is deleted from source before it's delivered to target. Data can be lost.
- Likely not what you want.
Exactly once - message will be deleted from source at the same time it's delivered to target.
- The holy grail. Very hard to achieve.
Ok, so you essentially want a Exactly once semantics. That can "only" be achieved when moving data between queues in the same broker, between tables in a database or by moving a file on a local disk (or internally in the same "resource").
When you have multiple protocols/resources, it's almost impossible, or at least very hard. There are some ways to somewhat ensure exactly once delivery using "two phase commit" transactions using a distributed transaction coordinator, such as MSDTC in Windows or Atomikos in Java (among others). Those will only support transactional resources, such as queues and databases, not file systems such as SMB.
Another way is to use the sagas-pattern. That pattern is maybe a bit overkill in this case though.
So what to do? Well - I can think of at least one way:
Idempotent consumer pattern. This makes Camel hold copies of each message (or a key at least, such as filename) in memory to ensure no single message will be delivered more that once.
// Something like this
from("smb://someplace?&idempotentKey=${file:name}&idempotent=true")
. // Whatnot
.to("activemq:queue:foobar");
Please note that you can configure an idempotent repository to keep entries in database, disk or multiple other places if you want something more persistent (but also more complex).
Hi Petter I need to configure a project using react, PWA and Link-state apollo Can please you guide to some tutorial So that I can configure it at the best level.
– Profer
Jan 4 at 14:03
@Profer I guess that is best done as another question with relevant tags
– Petter Nordlander
Jan 4 at 14:20
add a comment |
Let's look into the different delivery patterns for messaging:
At least once - the message is deleted from source after it's delivered to target. Same message can be sent multiple times.
- This is what you got now.
At most once - the message is deleted from source before it's delivered to target. Data can be lost.
- Likely not what you want.
Exactly once - message will be deleted from source at the same time it's delivered to target.
- The holy grail. Very hard to achieve.
Ok, so you essentially want a Exactly once semantics. That can "only" be achieved when moving data between queues in the same broker, between tables in a database or by moving a file on a local disk (or internally in the same "resource").
When you have multiple protocols/resources, it's almost impossible, or at least very hard. There are some ways to somewhat ensure exactly once delivery using "two phase commit" transactions using a distributed transaction coordinator, such as MSDTC in Windows or Atomikos in Java (among others). Those will only support transactional resources, such as queues and databases, not file systems such as SMB.
Another way is to use the sagas-pattern. That pattern is maybe a bit overkill in this case though.
So what to do? Well - I can think of at least one way:
Idempotent consumer pattern. This makes Camel hold copies of each message (or a key at least, such as filename) in memory to ensure no single message will be delivered more that once.
// Something like this
from("smb://someplace?&idempotentKey=${file:name}&idempotent=true")
. // Whatnot
.to("activemq:queue:foobar");
Please note that you can configure an idempotent repository to keep entries in database, disk or multiple other places if you want something more persistent (but also more complex).
Let's look into the different delivery patterns for messaging:
At least once - the message is deleted from source after it's delivered to target. Same message can be sent multiple times.
- This is what you got now.
At most once - the message is deleted from source before it's delivered to target. Data can be lost.
- Likely not what you want.
Exactly once - message will be deleted from source at the same time it's delivered to target.
- The holy grail. Very hard to achieve.
Ok, so you essentially want a Exactly once semantics. That can "only" be achieved when moving data between queues in the same broker, between tables in a database or by moving a file on a local disk (or internally in the same "resource").
When you have multiple protocols/resources, it's almost impossible, or at least very hard. There are some ways to somewhat ensure exactly once delivery using "two phase commit" transactions using a distributed transaction coordinator, such as MSDTC in Windows or Atomikos in Java (among others). Those will only support transactional resources, such as queues and databases, not file systems such as SMB.
Another way is to use the sagas-pattern. That pattern is maybe a bit overkill in this case though.
So what to do? Well - I can think of at least one way:
Idempotent consumer pattern. This makes Camel hold copies of each message (or a key at least, such as filename) in memory to ensure no single message will be delivered more that once.
// Something like this
from("smb://someplace?&idempotentKey=${file:name}&idempotent=true")
. // Whatnot
.to("activemq:queue:foobar");
Please note that you can configure an idempotent repository to keep entries in database, disk or multiple other places if you want something more persistent (but also more complex).
answered Nov 17 '18 at 17:37
Petter NordlanderPetter Nordlander
19.3k43776
19.3k43776
Hi Petter I need to configure a project using react, PWA and Link-state apollo Can please you guide to some tutorial So that I can configure it at the best level.
– Profer
Jan 4 at 14:03
@Profer I guess that is best done as another question with relevant tags
– Petter Nordlander
Jan 4 at 14:20
add a comment |
Hi Petter I need to configure a project using react, PWA and Link-state apollo Can please you guide to some tutorial So that I can configure it at the best level.
– Profer
Jan 4 at 14:03
@Profer I guess that is best done as another question with relevant tags
– Petter Nordlander
Jan 4 at 14:20
Hi Petter I need to configure a project using react, PWA and Link-state apollo Can please you guide to some tutorial So that I can configure it at the best level.
– Profer
Jan 4 at 14:03
Hi Petter I need to configure a project using react, PWA and Link-state apollo Can please you guide to some tutorial So that I can configure it at the best level.
– Profer
Jan 4 at 14:03
@Profer I guess that is best done as another question with relevant tags
– Petter Nordlander
Jan 4 at 14:20
@Profer I guess that is best done as another question with relevant tags
– Petter Nordlander
Jan 4 at 14:20
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320231%2ffile-rollback-when-unable-to-delete-file-from-smb%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown