if (storeMessage(msg)) { Message msgCopy = new Message(); msgCopy.copyFrom(msg); messageQueueBuffer.add(msgCopy);
public void process(Exchange exchange) throws Exception { Integer pullRequestNumber = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST, Integer.class); java.util.List<CommitFile> response = pullRequestService.getFiles(getRepository(), pullRequestNumber); // copy the header of in message to the out message exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(response); }
@Override public void successCallback(String channel, Object message) { LOG.trace("PubNub response {}", message); exchange.getIn().setHeader(PubNubConstants.CHANNEL, channel); if (exchange.getPattern().isOutCapable()) { exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(message); } callback.done(false); }
private Message getMessageForResponse(Exchange exchange) { if (exchange.getPattern().isOutCapable()) { Message out = exchange.getOut(); out.copyFrom(exchange.getIn()); return out; } return exchange.getIn(); }
private Message getMessageForResponse(final Exchange exchange) { if (exchange.getPattern().isOutCapable()) { Message out = exchange.getOut(); out.copyFrom(exchange.getIn()); return out; } return exchange.getIn(); }
public static Message getMessageForResponse(final Exchange exchange) { if (exchange.getPattern().isOutCapable()) { Message out = exchange.getOut(); out.copyFrom(exchange.getIn()); return out; } return exchange.getIn(); } }
public static Message getMessageForResponse(final Exchange exchange) { if (exchange.getPattern().isOutCapable()) { Message out = exchange.getOut(); out.copyFrom(exchange.getIn()); return out; } return exchange.getIn(); } }
public void process(Exchange exchange) throws Exception { // copy the header of in message to the out message exchange.getOut().copyFrom(exchange.getIn()); ResultSet resultSet = execute(exchange.getIn()); getEndpoint().fillMessage(resultSet, exchange.getOut()); }
public void process(Exchange exchange) throws Exception { CommitFile file = exchange.getIn().getBody(CommitFile.class); Blob response = dataService.getBlob(getRepository(), file.getSha()); String text = response.getContent(); // By default, if blob encoding is base64 then we convert to UTF-8. If // base64 encoding is required, then must be explicitly requested if (response.getEncoding().equals(Blob.ENCODING_BASE64) && encoding != null && encoding.equalsIgnoreCase(Blob.ENCODING_UTF8)) { text = new String(Base64.decodeBase64(text)); } // copy the header of in message to the out message exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(text); }
public void process(Exchange exchange) throws Exception { Issue issue = new Issue(); String issueTitle = exchange.getIn().getHeader(GitHubConstants.GITHUB_ISSUE_TITLE, String.class); if (ObjectHelper.isEmpty(issueTitle)) { throw new IllegalArgumentException("Issue Title must be specified to create an issue"); } issue.setTitle(issueTitle); issue.setBody(exchange.getIn().getBody(String.class)); Issue finalIssue = issueService.createIssue(getRepository(), issue); // copy the header of in message to the out message exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(finalIssue); }
public void process(Exchange exchange) throws Exception { Signature service = initSignatureService(exchange); calculateSignature(exchange, service); byte[] signature = service.sign(); Message in = exchange.getIn(); clearMessageHeaders(in); Message out = exchange.getOut(); out.copyFrom(in); out.setHeader(config.getSignatureHeaderName(), new Base64().encode(signature)); }
public void process(Exchange exchange) throws Exception { Integer pullRequestNumber = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST, Integer.class); Integer inResponseTo = exchange.getIn().getHeader(GitHubConstants.GITHUB_INRESPONSETO, Integer.class); String text = exchange.getIn().getBody(String.class); Comment response; if (inResponseTo != null && inResponseTo > 0) { response = pullRequestService.replyToComment(getRepository(), pullRequestNumber, inResponseTo, text); } else { // Otherwise, just comment on the pull request itself. response = issueService.createComment(getRepository(), pullRequestNumber, text); } // support InOut if (exchange.getPattern().isOutCapable()) { // copy the header of in message to the out message exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(response); } }
/** * Creates the exchange for the next processor returned by * {@link #getProcessor()} from a source exchange. * * @param source * a source exchange. * @return exchange for the next processor. */ protected Exchange createDelegateExchange(Exchange source) { DefaultExchange result = new DefaultExchange(source.getContext()); result.getIn().copyFrom(source.getIn()); return result; }
/** * Returns the message where to write results. This method copies the * in-message to the out-message if the exchange is out-capable. * * @param exchange message exchange. * @return result message. */ public static Message prepareResult(Exchange exchange) { Message result = resultMessage(exchange); if (exchange.getPattern().isOutCapable()) { result.copyFrom(exchange.getIn()); } return result; }
public void process(Exchange exchange) throws Exception { String pullRequestNumberSHA = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST_HEAD_COMMIT_SHA, String.class); String text = exchange.getIn().getBody(String.class); CommitStatus status = new CommitStatus(); if (state != null) { status.setState(state); } if (targetUrl != null) { status.setTargetUrl(targetUrl); } if (text != null) { status.setDescription(text); } CommitStatus response = commitService.createStatus(getRepository(), pullRequestNumberSHA, status); // copy the header of in message to the out message exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(response); }
public void process(Exchange exchange) throws Exception { Integer pullRequestNumber = exchange.getIn().getHeader(GitHubConstants.GITHUB_PULLREQUEST, Integer.class); PullRequest pullRequest = pullRequestService.getPullRequest(getRepository(), pullRequestNumber); pullRequest.setState("closed"); pullRequest.setClosedAt(Calendar.getInstance().getTime()); pullRequest = pullRequestService.editPullRequest(getRepository(), pullRequest); // support InOut if (exchange.getPattern().isOutCapable()) { // copy the header of in message to the out message exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(pullRequest); } }
public static final int MESSAGE_CHECK_BTN_STILL_PRESSED = 1; public final Handler myGuiHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_CHECK_BTN_STILL_PRESSED: Button btn = (Button) findViewById(msg.arg1); if (btn.getTag() != null) { // button is still pressed Log.i("myBtn", "still pressed"); btn.performClick(); // perform Click or different long press action Message msg1 = new Message(); // schedule next btn pressed check msg1.copyFrom(msg); myGuiHandler.sendMessageDelayed(msg1, msg1.arg2); } break; } } };
@Override public void process(Exchange exchange) throws Exception { // update user's status Object in = exchange.getIn().getBody(); Status response; if (in instanceof StatusUpdate) { response = updateStatus((StatusUpdate) in); } else { String s = exchange.getIn().getMandatoryBody(String.class); response = updateStatus(s); } /* * Support the InOut exchange pattern in order to provide access to * the unique identifier for the published tweet which is returned in the response * by the Twitter REST API: https://dev.twitter.com/docs/api/1/post/statuses/update */ if (exchange.getPattern().isOutCapable()) { // here we just copy the header of in message to the out message exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(response); } }
/** * Copies the <code>source</code> exchange to <code>target</code> exchange * preserving the {@link ExchangePattern} of <code>target</code>. * * @param source source exchange. * @param target target exchange. * * @see #resultMessage(Exchange) */ public static void copyExchange(Exchange source, Exchange target) { if (source == target) { // no need to copy return; } // copy in message target.getIn().copyFrom(source.getIn()); // copy out message if (source.hasOut()) { resultMessage(target).copyFrom(source.getOut()); } // copy exception target.setException(source.getException()); // copy properties target.getProperties().putAll(source.getProperties()); }
private void processMessage(Exchange exchange, AsyncCallback callback, PNStatus status, Object body) { if (status.isError()) { PNErrorData errorData = status.getErrorData(); exchange.setException(errorData.getThrowable()); if (errorData != null && errorData.getThrowable() instanceof PubNubException) { PubNubException pubNubException = (PubNubException) errorData.getThrowable(); throw new RuntimeException(pubNubException.getPubnubError().getMessage(), errorData.getThrowable()); } throw new RuntimeException(status.getErrorData().getThrowable()); } if (exchange.getPattern().isOutCapable()) { exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(body); } else { exchange.getIn().setBody(body); } // signal exchange completion callback.done(false); }