copper-server-api/src/main/java/com/pogeyan/cmis/api/BaseActor.java
/**
	 * Processing the message from sender.
	 * 
	 * @param sender
	 *            The sender Actorref
	 * @param b
	 *            the base message
	 */
Processing the message from sender.

@param sender
The sender Actorref
@param b
the base message
Processing the message from sender . @param sender The sender Actorref @param b the base message
private void doProcess(final ActorRef sender, BaseMessage b) {
		if (logger.isTraceEnabled()) {
			logger.trace("Processing the message from sender: {}, messageId: {}", sender, b.getMessageId());
		}
		if (this.messageHandles.containsKey(b.getActionName())) {
			if (logger.isDebugEnabled()) {
				logger.debug("Message handle identified for sender:{} with messageId: {}, actionName: {}", sender,
						b.getMessageId(), b.getActionName());
			}
			final ActorHandleContext ctx = this.messageHandles.get(b.getActionName());
			T tIn = b.getMessageAsType(ctx.decoderType);
			if (tIn != null) {
				if (logger.isDebugEnabled()) {
					logger.debug("Message decoded for sender:{} with messageId: {}", sender, b.getMessageId());
				}
				if (Helpers.isPerfMode()) {
					HashMap<String, String> headers = b.getBaggage(REQUEST_HEADERS);
					ISpan parentSpan = TracingApiServiceFactory.getApiService().startSpan(b.getMessageId(), null,
							"BaseActor::" + b.getTypeName() + "::" + b.getActionName(), headers);
					b.addBaggage(TRACINGID, b.getMessageId());
					b.addBaggage(PARENT_SPAN, parentSpan);
					this.traceContext.put(b.getMessageId(), parentSpan);
					if (headers.get(TRACING) != null && Boolean.valueOf(headers.get(TRACING))) {
						BaseRequest req = (BaseRequest) tIn;
						if (req != null) {
							TracingApiServiceFactory.getApiService().updateSpan(parentSpan,
									TracingMessage.message(
											TracingWriter.log(String.format(BASE_MESSAGE, b.getActionName(),
													b.getTypeName(), req.toString()), parentSpan),
											this.getClass().getSimpleName(), req.getRepositoryId(), false));
						}
					}
				}
				CompletableFuture<R> f_response = ctx.fn.apply(tIn, b.getBaggage());
				if (Helpers.isPerfMode()) {
					Timer.Context timerContext = MetricsInputs.get()
							.getTimer("TimerClass_" + b.getTypeName() + "_" + b.getActionName()).time();
					perfTimerContext.put(b.getMessageId(), timerContext);
				}
				f_response.thenAcceptAsync((resp) -> {
					BaseMessage respMessage = b.clone(MessageType.RESPONSE);
					if (resp == null || resp != null && !StringUtils.isBlank(resp.getError())) {
						if (logger.isDebugEnabled()) {
							logger.debug("no response found for message: {}, replying with MessageType.ERROR",
									b.getMessageId());
						}
						respMessage.setMessageInternal(((CmisBaseResponse) resp).getCmisData());
						respMessage.setMessageType(MessageType.ERROR);
					} else {
						if (resp instanceof CmisBaseResponse) {
							if (logger.isDebugEnabled()) {
								logger.debug("Message has CmisBaseResponse for messageId: {}", b.getMessageId());
							}
							respMessage.setMessageInternal(((CmisBaseResponse) resp).getCmisData());
						} else {
							respMessage.setMessageInternal(resp);
						}
						if (logger.isDebugEnabled()) {
							logger.debug("Response for messageId: {}, message: {} ", respMessage.getMessageId(),
									respMessage.getMessagePlain());
						}
					}
					sender.tell(respMessage, this.getSelf());
					if (Helpers.isPerfMode()) {
						Timer.Context timerContextStop = this.perfTimerContext.get(b.getMessageId());
						if (timerContextStop != null) {
							timerContextStop.stop();
							this.perfTimerContext.remove(b.getMessageId());
						}
						TracingApiServiceFactory.getApiService().endSpan(b.getMessageId(),
								this.traceContext.get(b.getMessageId()), false);
						this.traceContext.remove(b.getMessageId());
					}
				}).exceptionally((err) -> {
					logger.error("Exception in processing function : {}, {}, {}", b.getTypeName(), b.getActionName(),
							err.getMessage());
					BaseMessage respMessage = b.clone(MessageType.ERROR);
					respMessage.setMessageId(b.getMessageId());
					sender.tell(respMessage, this.getSelf());
					return null;
				});
			} else {
				reportError(sender, b);
			}
		} else {
			reportError(sender, b);
		}
	}
private void doProcess ( final ActorRef sender , BaseMessage b ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Processing the message from sender: {}, messageId: {}" , sender , b . getMessageId ( ) ) ; } if ( this . messageHandles . containsKey ( b . getActionName ( ) ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Message handle identified for sender:{} with messageId: {}, actionName: {}" , sender , b . getMessageId ( ) , b . getActionName ( ) ) ; } final ActorHandleContext ctx = this . messageHandles . get ( b . getActionName ( ) ) ; T tIn = b . getMessageAsType ( ctx . decoderType ) ; if ( tIn != null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Message decoded for sender:{} with messageId: {}" , sender , b . getMessageId ( ) ) ; } if ( Helpers . isPerfMode ( ) ) { HashMap < String , String > headers = b . getBaggage ( REQUEST_HEADERS ) ; ISpan parentSpan = TracingApiServiceFactory . getApiService ( ) . startSpan ( b . getMessageId ( ) , null , "BaseActor::" + b . getTypeName ( ) + "::" + b . getActionName ( ) , headers ) ; b . addBaggage ( TRACINGID , b . getMessageId ( ) ) ; b . addBaggage ( PARENT_SPAN , parentSpan ) ; this . traceContext . put ( b . getMessageId ( ) , parentSpan ) ; if ( headers . get ( TRACING ) != null && Boolean . valueOf ( headers . get ( TRACING ) ) ) { BaseRequest req = ( BaseRequest ) tIn ; if ( req != null ) { TracingApiServiceFactory . getApiService ( ) . updateSpan ( parentSpan , TracingMessage . message ( TracingWriter . log ( String . format ( BASE_MESSAGE , b . getActionName ( ) , b . getTypeName ( ) , req . toString ( ) ) , parentSpan ) , this . getClass ( ) . getSimpleName ( ) , req . getRepositoryId ( ) , false ) ) ; } } } CompletableFuture < R > f_response = ctx . fn . apply ( tIn , b . getBaggage ( ) ) ; if ( Helpers . isPerfMode ( ) ) { Timer . Context timerContext = MetricsInputs . get ( ) . getTimer ( "TimerClass_" + b . getTypeName ( ) + "_" + b . getActionName ( ) ) . time ( ) ; perfTimerContext . put ( b . getMessageId ( ) , timerContext ) ; } f_response . thenAcceptAsync ( ( resp ) -> { BaseMessage respMessage = b . clone ( MessageType . RESPONSE ) ; if ( resp == null || resp != null && ! StringUtils . isBlank ( resp . getError ( ) ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "no response found for message: {}, replying with MessageType.ERROR" , b . getMessageId ( ) ) ; } respMessage . setMessageInternal ( ( ( CmisBaseResponse ) resp ) . getCmisData ( ) ) ; respMessage . setMessageType ( MessageType . ERROR ) ; } else { if ( resp instanceof CmisBaseResponse ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Message has CmisBaseResponse for messageId: {}" , b . getMessageId ( ) ) ; } respMessage . setMessageInternal ( ( ( CmisBaseResponse ) resp ) . getCmisData ( ) ) ; } else { respMessage . setMessageInternal ( resp ) ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Response for messageId: {}, message: {} " , respMessage . getMessageId ( ) , respMessage . getMessagePlain ( ) ) ; } } sender . tell ( respMessage , this . getSelf ( ) ) ; if ( Helpers . isPerfMode ( ) ) { Timer . Context timerContextStop = this . perfTimerContext . get ( b . getMessageId ( ) ) ; if ( timerContextStop != null ) { timerContextStop . stop ( ) ; this . perfTimerContext . remove ( b . getMessageId ( ) ) ; } TracingApiServiceFactory . getApiService ( ) . endSpan ( b . getMessageId ( ) , this . traceContext . get ( b . getMessageId ( ) ) , false ) ; this . traceContext . remove ( b . getMessageId ( ) ) ; } } ) . exceptionally ( ( err ) -> { logger . error ( "Exception in processing function : {}, {}, {}" , b . getTypeName ( ) , b . getActionName ( ) , err . getMessage ( ) ) ; BaseMessage respMessage = b . clone ( MessageType . ERROR ) ; respMessage . setMessageId ( b . getMessageId ( ) ) ; sender . tell ( respMessage , this . getSelf ( ) ) ; return null ; } ) ; } else { reportError ( sender , b ) ; } } else { reportError ( sender , b ) ; } }
Processing the message from sender.
Processing the message from sender .
// inform the original sender of the reply