Axon Server - send events when the application starts - event-sourcing

My situation is as follows:
I have two microservices. When the first emits an event, the other correctly receives it;
If the first emits an event and the second microservice is off, when I turn on the second microservice, it does not receive the event.
edit:
I'm trying saga, when I issue a command I get it on the second service only if it is on.
the error I get is:
2020-04-06 13:53:40.341 WARN 1188 --- [-worker-ELG-3-1] i.a.a.message.command.C
ommandDispatcher : No Handler for command: com.progressivecoder.ecommerce.comma
nds.CreateInvoiceCommand
2020-04-06 13:54:38.707 WARN 1188 --- [nio-8024-exec-8] .w.s.m.s.DefaultHandler
ExceptionResolver : Async request timed out
2020-04-06 13:54:41.514 WARN 1188 --- [nio-8024-exec-8] .w.s.m.s.DefaultHandler
ExceptionResolver : Resolved [org.springframework.web.context.request.async.Asyn
cRequestTimeoutException]
2020-04-06 13:55:01.699 WARN 1188 --- [nio-8024-exec-9] .w.s.m.s.DefaultHandler
ExceptionResolver : Async request timed out
2020-04-06 13:55:01.700 WARN 1188 --- [nio-8024-exec-9] .w.s.m.s.DefaultHandler
ExceptionResolver : Resolved [org.springframework.web.context.request.async.Asyn
cRequestTimeoutException]
reading the guide, I realized that I have to configure the command bus to work in asynchronous;
is there an example from which I can get ideas?
thanks.

In Axon Server do you see the event that you emitted when you run a query in the search tab? Do you see the second microservice in the overview tab and does it show the tracking event processor in the application details?
Marc

Related

Spring Integration Mail IMAP - multiple receiver

I'm using spring boot 2.2.4.RELEASE
I need to build a dynamic mail receiver because I can have several mail server where to fetch mails. The mail server must be configurable by other systems so my requirement is to be dynamically able in fetching messages.
I investigated and I liked the Spring Integration solution and its DSL (note: it's enough to me to simply download messages and their attachments, if any).
So I built this code:
String flowId = MAIL_IN_FLOW_ID_PREFIX+cpd.getIndirizzoMail();
if( flowContext.getRegistrationById(flowId) != null ) {
flowContext.remove(flowId);
}
ImapMailInboundChannelAdapterSpec adapterSpec = Mail.imapInboundAdapter(connectionUrl.toString())
.javaMailProperties(javaMailProperties)
.shouldDeleteMessages(false)
.shouldMarkMessagesAsRead(false)
.selector(selectFunction);
if( confMailIn.isRichiedeAutenticazione() ) {
adapterSpec = adapterSpec.javaMailAuthenticator(new CasellaPostaleAuthenticator(cpd.getUsername(), cpd.getPassword()));
}
IntegrationFlow flow = IntegrationFlows
.from(adapterSpec.get(), e -> e.poller(Pollers.fixedDelay(Duration.ofSeconds(pollingSeconds)).maxMessagesPerPoll(maxMailMessagePerPoll)))
.handle(message -> {
logger.info("Message headers "+message.getHeaders());
logger.info("Message payload "+message.getPayload());
})
.get();
flowContext.registration(flow).id(flowId).register();
I tried by using my gmail account. The code is able in connecting to GMAIL by imap but, when I try to simply log messages, I get this error:
A6 OK Success
2020-02-05 12:48:41,835 23412 [task-scheduler-1] DEBUG
o.s.i.mail.ImapMailReceiver - Received 10 messages
2020-02-05 12:48:41,836 23413 [task-scheduler-1] DEBUG oA7 STORE 1
+FLAGS (\Flagged) .s.i.mail.ImapMailReceiver - USER flags are not supported by this mail server. Flagging message with system flag
A7 NO STORE attempt on READ-ONLY folder (Failure)
A8 CLOSE
A8 OK Returned to authenticated state. (Success)
DEBUG IMAP: added an Authenticated connection -- size: 1
2020-02-05 12:48:42,198 23775 [task-scheduler-1] ERROR
o.s.i.handler.LoggingHandler -
org.springframework.messaging.MessagingException: failure occurred
while polling for mail; nested exception is
javax.mail.MessagingException: A7 NO STORE attempt on READ-ONLY folder
(Failure); nested exception is:
com.sun.mail.iap.CommandFailedException: A7 NO STORE attempt on
READ-ONLY folder (Failure) at
org.springframework.integration.mail.MailReceivingMessageSource.doReceive(MailReceivingMessageSource.java:74)
at
org.springframework.integration.endpoint.AbstractMessageSource.receive(AbstractMessageSource.java:167)
at
org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:250)
Now it seems that by default the FOLDER is opened in READ_ONLY way and this seems to cause an error.
I'm stucked here and I can't figure out how to solve the issue.
May anybody give me a tip?
Thank you
Angelo
adapterSpec.get()
Issuing a get() on the spec circumvents Spring's bean initialization logic which switches the folder to read/write.
Either make the adapter a #Bean or simply remove the .get() and Spring will perform the initialization.
.from(adapterSpec, e -> ...

Download failed because you may not have purchased this app - emulator

Dears,
My apk expansion is working fine with real devices, but with emulator I get this error
Download failed because you may not have purchased this app
This is the logcat:
BE/Checking_download: expansion not delivered
E/Checking_download: try intent
E/Checking_download: intented launched
E/Checking_download: Category isandroid.intent.category.LAUNCHER
E/Checking_download: Start the download service
E/Checking_download: initialize activity to show progress , result is: 2
ro.sf.lcd_density must be defined as a build property
[ 04-25 00:08:50.630 8167: 8167 D/ ]
HostConnection::get() New Host Connection established 0x9f4b1d40, tid 8167
E/Checking_download: service_resume :
[ 04-25 00:08:50.828 8167: 8190 D/ ]
HostConnection::get() New Host Connection established 0xa1fdf2c0, tid 8190
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
E/Checking_download: service_to_connected :
E/Checking_download: service_connected :
E/FA: Discarding data. Failed to send app launch
E/FA: Failed to get app instance id
E/FA: Failed to send current screen to service
E/FA: Discarding data. Failed to send event to service
E/Checking_download: DownloadStateChanged : Looking for resources to download
E/Checking_download: DownloadStateChanged : Download failed because you may not have purchased this app
Notes:
1-Again app live on google play working fine with real devices.
2-Emulator API version is : google play API-25.
3-Google account is added to emulator. ( logged in with my gmail).
4-Google play services installed.
Thanks in advance.
The answer is very simple, the application version code must be same like uploaded version to google play.
i.e ( in build.gradle, app level check
versionCode 2
Then you have to confirm from google play that this version is already uploaded and life.

Enabling Jersey trace logging causes MaxHeaderCountExceededException

I am trying to debug my jersey 2 app on Payara 162, but on every request, after the trace information is printed I get this exception and the client gets no response:
org.glassfish.grizzly.http.util.MimeHeaders$MaxHeaderCountExceededException: Illegal attempt to exceed the configured maximum number of headers: 100
at org.glassfish.grizzly.http.util.MimeHeaders.createHeader(MimeHeaders.java:396)
at org.glassfish.grizzly.http.util.MimeHeaders.addValue(MimeHeaders.java:422)
at org.glassfish.grizzly.http.HttpHeader.addHeader(HttpHeader.java:707)
at org.glassfish.grizzly.http.server.Response.addHeader(Response.java:1177)
at org.apache.catalina.connector.Response.addHeader(Response.java:1221)
at org.apache.catalina.connector.ResponseFacade.addHeader(ResponseFacade.java:579)
at org.glassfish.jersey.servlet.internal.ResponseWriter.writeResponseStatusAndHeaders(ResponseWriter.java:165)
at org.glassfish.jersey.server.ServerRuntime$Responder$1.getOutputStream(ServerRuntime.java:701)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200)
at org.glassfish.jersey.message.internal.CommittingOutputStream.flushBuffer(CommittingOutputStream.java:305)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commit(CommittingOutputStream.java:261)
at org.glassfish.jersey.message.internal.CommittingOutputStream.close(CommittingOutputStream.java:276)
at org.glassfish.jersey.message.internal.OutboundMessageContext.close(OutboundMessageContext.java:839)
at org.glassfish.jersey.server.ContainerResponse.close(ContainerResponse.java:412)
at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:784)
at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:444)
at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:434)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:329)
In my jersey I app I configured trace as so:
public class RestApplication extends ResourceConfig {
public RestApplication() {
super();
packages(true, "com.example");
register(JacksonFeature.class);
register(JsonProvider.class);
register(RolesAllowedDynamicFeature.class);
property("jersey.config.server.tracing.type", "ON_DEMAND");
property("jersey.config.server.tracing.threshold", "VERBOSE");
}
}
I enabled the logger in my logback.xml (I have configured Payara to use logback), and I see the full trace info in my server log when I enable it on demand by adding the X-Jersey-Tracing-Accept header to my request, but then I get the exception. When I don't add the header to the request everything works but of course I don't get the trace.
I'm wondering if there is anything I can change to fix this or is it a bug?
The problem is that tracing adds a header into the REST response for each event.
Grizzly imposes a limit on number of headers in the response.
Payara Server by default defines 100 as maximum number of headers in the response. You need to increase this number to allow all tracing info in the response.
To set a higher number for maximum number of headers, you need to use asadmin. There is no option to set this in the GUI admin console, it is missing in the screen to configure the HTTP protocol.
If your configuration is named server-config and the network listener is http-listener-1, then execute the following asadmin command to set it to 1000:
asadmin> set
configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.max-response-headers=1000
You can use a similar command to set all Grizzly network listener propertiesoptions, just replace max-response-headers to the name of the option you want to set, using - as a word separator instead of camel case.

loopback + remote calls + debug

if there is a server error, my XHR will return a 500 error code along with a vague description.
what is the best practice on viewing error logs, debug output, etc?
can this output be sent to my console?
what will work for me now is using the debug object.
var debug = require('debug')('my:debug:string');
then specifying the debug string when launching the app.
DEBUG=my:debug:string node .

Firefox crashes after the url is being passed onto address bar

I am facing an issue with the Web driver sampler in J meter.
I have written a simple code in web driver sampler where i have given a url and passing few credentials to login.
When i run the test.. the browser gets invoked, the url is passed onto the address bar and then
the browser gets closed or crashes. Sometimes the browser gets crashed after passing the passwords. Pls have a look at the below code and let me know
if i am missing on something.
Code.
var pkg=JavaImporter(org.openqa.selenium) //import java selenium package
var support_ui=JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var ui=JavaImporter(org.openqa.selenium.support.ui)
var wait=new support_ui.WebDriverWait(WDS.browser,20000)
WDS.sampleResult.sampleStart()
WDS.browser.get('https://web2qa.westlaw.com/signon/default.wl?bhcp=1&fn=_top&newdoor=true&rs=WLW14.07&vr=2.0')
var Onepass=WDS.browser.findElement(pkg.By.id('OnePassHeaderLink'))
Onepass.click()
var usernameField = WDS.browser.findElement(pkg.By.id('pwd'))
usernameField.sendKeys(['pwd1'])
var passwordField = WDS.browser.findElement(pkg.By.id('clientid'))
passwordField.sendKeys(['pwd2'])
var loginButton=WDS.browser.findElement(pkg.By.id('login_submit'))
loginButton.click()
WDS.log.info(WDS.name + ' has logged an entry')
WDS.sampleResult.sampleEnd()
1.I did reduce the timeout period, Still the Issue persists.
2.i have added the code u mentioned even in the username Field and passwordField still the browser crashes once the page gets loaded.
3.Please find the screenshot and the error log below.
Error Log:
2014/07/22 01:27:56 INFO - jmeter.threads.JMeterThread: Running PostProcessors in forward order
2014/07/22 01:27:56 INFO - jmeter.threads.ThreadGroup: Started thread group number 1
2014/07/22 01:27:56 INFO - jmeter.engine.StandardJMeterEngine: All thread groups have been started
2014/07/22 01:27:56 INFO - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1
2014/07/22 01:28:09 INFO - com.googlecode.jmeter.plugins.webdriver.config.WebDriverConfig: iterationStart()
2014/07/22 01:28:09 INFO - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Current thread name: 'Thread Group 1-1', has browser: 'FirefoxDriver: firefox on XP (098965b0-fea8-4428-9e6e-76d1385cecc2)'
2014/07/22 01:28:22 ERROR - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: sun.org.mozilla.javascript.internal.WrappedException: Wrapped org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"login_submit"}
Command duration or timeout: 32 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.34.0', revision: '11cd0ef93615408e0b6b3bfa28defe125906461a', time: '2013-08-06 11:43:14'
System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_37'
Session ID: 098965b0-fea8-4428-9e6e-76d1385cecc2
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=16.0.2, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}] (#18) in at line number 18
2014/07/22 01:28:22 INFO - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-1
2014/07/22 01:28:22 INFO - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test
2014/07/22 01:28:22 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(false,local)
First of all WebDriverWait(WDS.browser,20000)
Are you sure that 20000 seconds is correct timeout for waiting element to appear? It's 5.5 hours. If you need 20 seconds just put 20 in there.
Second:
Elements may not be loaded immediately after browser.get request. For instance if element is being loaded with AJAX it may take some additional time for it to appear in DOM and WebDriver could interact with it.
So I would suggest something like:
WDS.browser.get('https://web2qa.westlaw.com/signon/default.wl?bhcp=1&fn=_top&newdoor=true&rs=WLW14.07&vr=2.0')
wait.until(ui.ExpectedConditions.presenceOfElementLocated(pkg.By.id('OnePassHeaderLink')))
var Onepass=WDS.browser.findElement(pkg.By.id('OnePassHeaderLink'))
Onepass.click()
Apply the same for usernameField, passwordField, etc.
Third: If you still experience any problems add View Results Tree listener or inspect jmeter.log file to find out the reason of your test failure and update your question with error messages as Stack Overflow community is not telepathic enough to guess what's wrong with your test.
See Using Selenium with JMeter's WebDriver Sampler guide for more details on how to use WebDriver Sampler.

Resources