Skip to content

Commit

Permalink
Initial version of Exception handling according to Camel best practices.
Browse files Browse the repository at this point in the history
  • Loading branch information
trifonnt committed Jul 19, 2016
1 parent f96d1c8 commit 1b7e0e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>com.github.trifonnt</groupId>
<artifactId>camel-mws-product</artifactId>
<version>1.0.0.alpha.1</version>
<version>1.0.0-alpha.2</version>

<name>Camel MWS Product Component</name>
<url>https://github.com/trifonnt/camel-mws-product</url>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.apache.camel.component.mws.product;

import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.impl.DefaultProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -38,14 +39,17 @@ public MWSProductProducer(MWSProductEndpoint endpoint) {

@Override
public void process(Exchange exchange) throws Exception {
// LOG.debug( exchange.getIn().getBody().toString() );
LOG.debug("marketplaceId={}, merchantId={}", endpoint.getMarketplaceId(), endpoint.getMerchantId());
Message msg = exchange.getOut();

// Get the searchString from the HTTP Request Parameters(Camel Exchange Header)
String searchString = (String) exchange.getIn().getHeader("mwsSearchString");
LOG.debug("searchString={}", searchString);
if (searchString == null || searchString.isEmpty()) {
throw new IllegalArgumentException("SearchString is mandatory!");
// throw new IllegalArgumentException("SearchString is mandatory!");
msg.setFault( true );
msg.setBody("SearchString is mandatory!");
return;
}

String searchContext = (String) exchange.getIn().getHeader("mwsSearchContext");
Expand Down

0 comments on commit 1b7e0e0

Please sign in to comment.