Re: Idempotent consumer question

2011-06-21 Thread Jesse Sanford
I don't think anyone thought you were intentionally being rude. I
think that new users to the list may not realize that it takes a few
hours sometimes days to get clear responses. Is there a policy on
bumping topics on this list yet?

J

On Tue, Jun 21, 2011 at 11:34 AM, mcaserta mirko.case...@gmail.com wrote:
 I didn't mean to be rude and I'm terribly sorry if my comment struck a nerve.

 I can make you sure that I know how open source works and I value the Camel
 project and the people behind it more than you might think. That's the
 reason why I came here to ask a question in the first place and proposed to
 contribute patches.

 Again, sorry.

 Mirko

 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Idempotent-consumer-question-tp4510383p4511047.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: need help with interceptor in camel 1.6.2 using custom predicate

2010-04-12 Thread Jesse Sanford
Claus, Thanks for your help. Of course you deserve the kudos!

I tried the filter method that you described with 1.6.2 and I also upgraded
to 2.2 and tried again with interceptors and also with choice().when()

What I am finding is this. When I use the custom predicate:

public class commentFilter implements Predicate {
public static final Log log = LogFactory.getLog(commentFilter.class);

//camel 1.x
//public boolean matches(Object ex) {
public boolean matches(Exchange exchange) {
log.debug(Starting filter);

//came 1.x
//Exchange exchange = (Exchange)ex;
String email = exchange.getIn().getBody(Comment.class).getEmail();
if(email.equalsIgnoreCase(jessesanf...@gmail.com)) {
log.debug(Skipping this exchange because it was  +
  sent by blacklisted email address:  + email);

return false;
} else {
log.debug(Email not blacklisted. Allowing exchange to be routed
 +
  email);

return true;
}
}

//camel 1.x
//public void assertMatches(String s, Object o) {
//do nothing
//this just satisfies the interface
//}
}

It only executes the predicate one time. On the first message that is
passed. I can tell this because I see the following in the logs:

18:19:03,894 DEBUG CommentCaptureController:captureWithJms:117 -
captureWithJms
18:19:03,894 DEBUG CommentCaptureController:captureWithJms:117 -
captureWithJms
18:19:03,895 DEBUG CommentCaptureController:capture:88 - Start
18:19:03,895 DEBUG CommentCaptureController:capture:88 - Start
18:19:03,896 DEBUG JmsCatcher:catchComment:84 - sending a message.
18:19:03,896 DEBUG JmsCatcher:catchComment:84 - sending a message.
18:19:03,923  INFO SingleConnectionFactory:initConnection:293 - Established
shared JMS Connection: PooledConnection {
org.apache.activemq.pool.connectionp...@4800ef96 }
18:19:03,934  INFO FailoverTransport:doReconnect:756 - Successfully
connected to tcp://localhost:61716
18:19:04,024  INFO VelocityEngine:logVelocityMessage:49 - ResourceManager :
found index.vm with loader
org.apache.velocity.runtime.resource.loader.FileResourceLoader
18:19:04,077 DEBUG commentFilter:matches:25 - Starting filter
18:19:04,077 DEBUG commentFilter:matches:25 - Starting filter
18:19:04,079 DEBUG commentFilter:matches:31 - Skipping this exchange because
it was sent by blacklisted email address: jessesanf...@gmail.com
18:19:04,079 DEBUG commentFilter:matches:31 - Skipping this exchange because
it was sent by blacklisted email address: jessesanf...@gmail.com
18:19:28,423 DEBUG CommentCaptureController:captureWithJms:117 -
captureWithJms
18:19:28,423 DEBUG CommentCaptureController:captureWithJms:117 -
captureWithJms
18:19:28,424 DEBUG CommentCaptureController:capture:88 - Start
18:19:28,424 DEBUG CommentCaptureController:capture:88 - Start
18:19:28,424 DEBUG JmsCatcher:catchComment:84 - sending a message.
18:19:28,424 DEBUG JmsCatcher:catchComment:84 - sending a message.
18:19:28,597 DEBUG JdbcCatcher:capture:204 - done
18:19:28,597 DEBUG JdbcCatcher:capture:204 - done


You can see that on the second submit (of the same exact data so the
exchange should hold the same info) that the predicate is not run or at
least it does not fire the section of the code that has my log message in
it.

Can you think of any reason why this might be?

Ultimately I would like to have the predicate do a jdbc call to a
blacklisted email table to check that the messages are allowed through
before processing them.

Am I pursuing this in the wrong fashion?

How would you go about achieving this functionality?

Thanks so much!

Jesse

On Mon, Apr 12, 2010 at 12:09 AM, Claus Ibsen claus.ib...@gmail.com wrote:

 Hi Jesse

 btw thanks for the kudo.

 The interceptors in Camel 1.x is not working super duper.
 And hence why they have been overhauled in the 2.0 onwards, which
 would allow you to do what you want.

 I suggest to search in the camel-core src/test/java directory for any
 intercept unit tests and see if you can find an example that looks
 like what you are doing.

 I assume upgrading to 2.x is not an option. You may instead want to
 use a Filter EIP in 1.x to build a solution where you can use the
 predicate to include the good messages in the filter. Then the bad
 messages can be skipped.


 On Sun, Apr 11, 2010 at 11:11 PM, Jesse Sanford jessesanf...@gmail.com
 wrote:
  I am trying to intercept an exchange using a custom predicate and I am
  having trouble re-routing the exchange or even simply stoping it.
 
  Here is my routebuilder:
 
  public class commentRoute extends RouteBuilder{
 @Override
 public void configure(){
 intercept().when(isBlacklisted()).to(mock:intercepted).stop();
 from(comment-queue).to(comment-catcher);
 }
 
 private Predicate isBlacklisted(){
 return new Predicate(){
 public boolean matches(Object ex) {
 Exchange exchange

Re: need help with interceptor in camel 1.6.2 using custom predicate

2010-04-12 Thread Jesse Sanford
FYI Here is my routeConfigurator class. You can see from the commented out
sections in the configure method that I have tried a lot of different dsl
configurations.

public class commentRoute extends RouteBuilder {
private Predicate commentFilter;

@Override
public void configure(){
//intercept().when(isBlacklisted()).to(log:comment).stop();
//intercept().to(log:comment).stop();
//from(comment-queue).to(comment-catcher);

//from(comment-queue).filter(commentFilter).to(comment-catcher);

errorHandler(
deadLetterChannel(jms:queue:incoming.deadletterqueue).
delayPattern(20s).
maximumRedeliveries(5)
);

from(comment-queue).
choice().when(commentFilter).to(comment-catcher).
otherwise().to(jms:queue:incoming.invalid);
}

/**
 * Your standard getter
 * @return the commentFilter
 */
public Predicate getCommentFilter() {
return commentFilter;
}

/**
 * Your standard setter
 * @param commentFilter the commentFilter to set
 */
public void setCommentFilter(Predicate commentFilter) {
this.commentFilter = commentFilter;
}

private Predicate isBlacklisted(){
return new Predicate(){
public boolean matches(Exchange exchange) {
String email =
exchange.getIn().getBody(Comment.class).getEmail();
if(email.equalsIgnoreCase(jessesanf...@gmail.com)) {
return true;
} else {
return false;
}
}
};
}

}


On Mon, Apr 12, 2010 at 6:28 PM, Jesse Sanford jessesanf...@gmail.comwrote:

 Claus, Thanks for your help. Of course you deserve the kudos!

 I tried the filter method that you described with 1.6.2 and I also upgraded
 to 2.2 and tried again with interceptors and also with choice().when()

 What I am finding is this. When I use the custom predicate:

 public class commentFilter implements Predicate {
 public static final Log log = LogFactory.getLog(commentFilter.class);

 //camel 1.x
 //public boolean matches(Object ex) {
 public boolean matches(Exchange exchange) {
 log.debug(Starting filter);

 //came 1.x
 //Exchange exchange = (Exchange)ex;

 String email = exchange.getIn().getBody(Comment.class).getEmail();
 if(email.equalsIgnoreCase(jessesanf...@gmail.com)) {
 log.debug(Skipping this exchange because it was  +
   sent by blacklisted email address:  + email);

 return false;
 } else {
 log.debug(Email not blacklisted. Allowing exchange to be
 routed  +
   email);

 return true;
 }
 }

 //camel 1.x
 //public void assertMatches(String s, Object o) {

 //do nothing
 //this just satisfies the interface
 //}
 }

 It only executes the predicate one time. On the first message that is
 passed. I can tell this because I see the following in the logs:

 18:19:03,894 DEBUG CommentCaptureController:captureWithJms:117 -
 captureWithJms
 18:19:03,894 DEBUG CommentCaptureController:captureWithJms:117 -
 captureWithJms
 18:19:03,895 DEBUG CommentCaptureController:capture:88 - Start
 18:19:03,895 DEBUG CommentCaptureController:capture:88 - Start
 18:19:03,896 DEBUG JmsCatcher:catchComment:84 - sending a message.
 18:19:03,896 DEBUG JmsCatcher:catchComment:84 - sending a message.
 18:19:03,923  INFO SingleConnectionFactory:initConnection:293 - Established
 shared JMS Connection: PooledConnection {
 org.apache.activemq.pool.connectionp...@4800ef96 }
 18:19:03,934  INFO FailoverTransport:doReconnect:756 - Successfully
 connected to tcp://localhost:61716
 18:19:04,024  INFO VelocityEngine:logVelocityMessage:49 - ResourceManager :
 found index.vm with loader
 org.apache.velocity.runtime.resource.loader.FileResourceLoader
 18:19:04,077 DEBUG commentFilter:matches:25 - Starting filter
 18:19:04,077 DEBUG commentFilter:matches:25 - Starting filter
 18:19:04,079 DEBUG commentFilter:matches:31 - Skipping this exchange
 because it was sent by blacklisted email address: jessesanf...@gmail.com
 18:19:04,079 DEBUG commentFilter:matches:31 - Skipping this exchange
 because it was sent by blacklisted email address: jessesanf...@gmail.com
 18:19:28,423 DEBUG CommentCaptureController:captureWithJms:117 -
 captureWithJms
 18:19:28,423 DEBUG CommentCaptureController:captureWithJms:117 -
 captureWithJms
 18:19:28,424 DEBUG CommentCaptureController:capture:88 - Start
 18:19:28,424 DEBUG CommentCaptureController:capture:88 - Start
 18:19:28,424 DEBUG JmsCatcher:catchComment:84 - sending a message.
 18:19:28,424 DEBUG JmsCatcher:catchComment:84 - sending a message.
 18:19:28,597 DEBUG JdbcCatcher:capture:204 - done
 18:19:28,597 DEBUG JdbcCatcher:capture:204 - done


 You can see that on the second submit (of the same exact data so

Re: need help with interceptor in camel 1.6.2 using custom predicate

2010-04-12 Thread Jesse Sanford
I should mention that I am using spring 2.5.x

On Mon, Apr 12, 2010 at 6:30 PM, Jesse Sanford jessesanf...@gmail.comwrote:

 FYI Here is my routeConfigurator class. You can see from the commented out
 sections in the configure method that I have tried a lot of different dsl
 configurations.


 public class commentRoute extends RouteBuilder {
 private Predicate commentFilter;

 @Override
 public void configure(){
 //intercept().when(isBlacklisted()).to(log:comment).stop();
 //intercept().to(log:comment).stop();

 //from(comment-queue).to(comment-catcher);


 //from(comment-queue).filter(commentFilter).to(comment-catcher);

 errorHandler(
 deadLetterChannel(jms:queue:incoming.deadletterqueue).
 delayPattern(20s).
 maximumRedeliveries(5)
 );

 from(comment-queue).
 choice().when(commentFilter).to(comment-catcher).
 otherwise().to(jms:queue:incoming.invalid);
 }

 /**
  * Your standard getter
  * @return the commentFilter
  */
 public Predicate getCommentFilter() {
 return commentFilter;
 }

 /**
  * Your standard setter
  * @param commentFilter the commentFilter to set
  */
 public void setCommentFilter(Predicate commentFilter) {
 this.commentFilter = commentFilter;

 }

 private Predicate isBlacklisted(){
 return new Predicate(){
 public boolean matches(Exchange exchange) {

 String email =
 exchange.getIn().getBody(Comment.class).getEmail();
 if(email.equalsIgnoreCase(jessesanf...@gmail.com)) {
 return true;
 } else {
 return false;
 }
 }
 };

 }

 }


 On Mon, Apr 12, 2010 at 6:28 PM, Jesse Sanford jessesanf...@gmail.comwrote:

 Claus, Thanks for your help. Of course you deserve the kudos!

 I tried the filter method that you described with 1.6.2 and I also
 upgraded to 2.2 and tried again with interceptors and also with
 choice().when()

 What I am finding is this. When I use the custom predicate:

 public class commentFilter implements Predicate {
 public static final Log log = LogFactory.getLog(commentFilter.class);

 //camel 1.x
 //public boolean matches(Object ex) {
 public boolean matches(Exchange exchange) {
 log.debug(Starting filter);

 //came 1.x
 //Exchange exchange = (Exchange)ex;

 String email = exchange.getIn().getBody(Comment.class).getEmail();
 if(email.equalsIgnoreCase(jessesanf...@gmail.com)) {
 log.debug(Skipping this exchange because it was  +
   sent by blacklisted email address:  + email);

 return false;
 } else {
 log.debug(Email not blacklisted. Allowing exchange to be
 routed  +
   email);

 return true;
 }
 }

 //camel 1.x
 //public void assertMatches(String s, Object o) {

 //do nothing
 //this just satisfies the interface
 //}
 }

 It only executes the predicate one time. On the first message that is
 passed. I can tell this because I see the following in the logs:

 18:19:03,894 DEBUG CommentCaptureController:captureWithJms:117 -
 captureWithJms
 18:19:03,894 DEBUG CommentCaptureController:captureWithJms:117 -
 captureWithJms
 18:19:03,895 DEBUG CommentCaptureController:capture:88 - Start
 18:19:03,895 DEBUG CommentCaptureController:capture:88 - Start
 18:19:03,896 DEBUG JmsCatcher:catchComment:84 - sending a message.
 18:19:03,896 DEBUG JmsCatcher:catchComment:84 - sending a message.
 18:19:03,923  INFO SingleConnectionFactory:initConnection:293 -
 Established shared JMS Connection: PooledConnection {
 org.apache.activemq.pool.connectionp...@4800ef96 }
 18:19:03,934  INFO FailoverTransport:doReconnect:756 - Successfully
 connected to tcp://localhost:61716
 18:19:04,024  INFO VelocityEngine:logVelocityMessage:49 - ResourceManager
 : found index.vm with loader
 org.apache.velocity.runtime.resource.loader.FileResourceLoader
 18:19:04,077 DEBUG commentFilter:matches:25 - Starting filter
 18:19:04,077 DEBUG commentFilter:matches:25 - Starting filter
 18:19:04,079 DEBUG commentFilter:matches:31 - Skipping this exchange
 because it was sent by blacklisted email address: jessesanf...@gmail.com
 18:19:04,079 DEBUG commentFilter:matches:31 - Skipping this exchange
 because it was sent by blacklisted email address: jessesanf...@gmail.com
 18:19:28,423 DEBUG CommentCaptureController:captureWithJms:117 -
 captureWithJms
 18:19:28,423 DEBUG CommentCaptureController:captureWithJms:117 -
 captureWithJms
 18:19:28,424 DEBUG CommentCaptureController:capture:88 - Start
 18:19:28,424 DEBUG CommentCaptureController:capture:88 - Start
 18:19:28,424 DEBUG JmsCatcher:catchComment:84 - sending a message.
 18:19:28,424 DEBUG JmsCatcher:catchComment:84 - sending a message.
 18

need help with interceptor in camel 1.6.2 using custom predicate

2010-04-11 Thread Jesse Sanford
I am trying to intercept an exchange using a custom predicate and I am
having trouble re-routing the exchange or even simply stoping it.

Here is my routebuilder:

public class commentRoute extends RouteBuilder{
@Override
public void configure(){
intercept().when(isBlacklisted()).to(mock:intercepted).stop();
from(comment-queue).to(comment-catcher);
}

private Predicate isBlacklisted(){
return new Predicate(){
public boolean matches(Object ex) {
Exchange exchange = (Exchange)ex;
String email =
exchange.getIn().getBody(Comment.class).getEmail();
if(email.equalsIgnoreCase(jessesanf...@gmail.com)) {
return true;
} else {
return false;
}
}

public void assertMatches(String s, Object o) {
//do nothing
//this just satisfies the interface
}
};
}

}

I know that the predicate is being run because If I set a breakpoint at

if(email.equalsIgnoreCase(jessesanf...@gmail.com)) {


and step through the code from there the return true; is reached when i send
an exchange with the email address filled in with my email address.

Am I doing this all wrong? If this predicate is run and returns true why
doesn't camel respect my intercept re-routing or stoping?

Thanks so much,
jesse