Issue using StreamBridge in Spring Cloud Stream - spring-kafka

I have currently deployed this sample app standalone-stream-sample on my kubernetes cluster and am trying to modify the Sender application to use a StreamBridge to publish messages like below (instead of using the Supplier function):
streamBridge.send("sendEvents-out-0", usageDetail);
The flow for the stream looks like this:
usage-detail-sender app -> usage-cost-processor app -> usage-cost-logger app
But for some reason, when the message is sent by the sender, it is not picked up by the processor application. I'm not getting any errors (so it seems like it's being published somewhere), but how do I set it up to publish the messages so that the other app can pick them up. This is what the config looks like in application.properties for the sender app:
spring.cloud.stream.function.bindings.sendEvents-out-0=output
spring.cloud.stream.bindings.output.destination=usage-detail
This is what the config looks like for the processor app:
spring.cloud.stream.function.bindings.processUsageCost-in-0=input
spring.cloud.stream.function.bindings.processUsageCost-out-0=output
spring.cloud.stream.bindings.input.destination=usage-detail
spring.cloud.stream.bindings.output.destination=usage-cost

Related

Why does turning on Application Insights on a App Service crash the app?

I have turned on Application Insights on my app service. Everytime I try to run the app or login using the app it gives an error:
An error has occurred. Please call support or your account manager if this error persists
When i looked in the Application errors under Logging,I get the following:
System.ApplicationException: The trace listener AzureBlobTraceListener is disabled.
---> System.InvalidOperationException: The SAS URL for the cloud storage account is not
specified. Use the environment variable
'DIAGNOSTICS_AZUREBLOBCONTAINERSASURL' to define it.
Im assuming I need to add the following in the Configuration of the App Service:
{
"name": "DIAGNOSTICS_AZUREBLOBCONTAINERSASURL",
"value": <URL>,
"slotSetting": true
},
But what is the and where can i find it ? Or is there a different error causing the app to crash once application insights is enabled, has anyone experienced this ?
I can see you have configured DIAGNOSTICS_AZUREBLOBCONTAINERSASURL without providing the value.
Get the Blob service SAS URL value from the Storage Account.
In Azure Portal => Create a Storage Account.
Initially the option to generate SAS is disabled for me.
Navigate to your Storage Account => Shared access signature = > select Container and Object checkboxes.
An option to Generate SAS and connection string will be enabled.
Copy the Blob service SAS URL and provide the value in either local Configuration settings or in Azure App Service => Configuration => Application Settings.
In Azure App Service Settings
Save the settings and access the URL.
My question before is that once i generate Generate SAS and Conection string and copy to clip board.
Even if you generate the SAS again, the value will be same till here - https://yourSA.blob.core.windows.net/?sv=2021-06-08&ss=*****=co&sp=******&se=2022-12-05T14:.
Even we can add the SAS token in App settings automatically. Follow the below steps.
In Azure App Service => App Service logs = >set Application logging (Blob) to On and continue the steps to add the Storage Account. If you don't have create a new Storage Account.
"Unable to find mscorlib assembly reference:.
Make sure you are using the latest package references.
Update the framework version 4.7.2 to 4.8 in VS. Rebuild and Re-deploy the App.

how to get the pipeline name dynamically in ADF?

I am trying to implement mail notification in pipeline in ADF.
So basically I want to send the a notification mail about the successful execution of pipeline in ADF.
I have created a demo pipeline where I m coping the data. this is working fine.
And I have created a SSIS pkg that will send email notification(also working fine.)
Now I want to have the pipeline name so that the notification will have pipeline name also dynamically.
You can use the following expression which uses system variables to get the current pipeline name:
#pipeline().Pipeline
See this link for more system variables.

Using Serilog with .Net core and App Insights

I have used App insights directly for application logging before and I have seen that .Net core platform also creates trace events that goes to App insights.
In a new .Net core API application, I'd like to use Serilog for application logging and App Insight for storing and visualizing the log events. I'd like to know:
How to continue to get the .Net core .created trace events to App insights?
How can I pass correlation Id from my application to .Net core created trace events?
Will end to end transaction feature in App insight portal show all the events together? It is important for me to know and keep an eye on the latency of SQL calls.
Simply using Serilog.Sinks.ApplicationInsights is not enough, as it will not correlate Serilog events with the rest of your telemetry on Application Insights.
To correlate the events, so they are shown as one "End-to-End transaction" - you have to do the following things:
Create a Serilog enricher that would record the current Activity id as a ScalarValue in a LogEventProperty - see OperationIdEnricher
[Optional] Create an extension for this enricher - see LoggingExtensions
Register the enricher / add it to the pipeline via code or config - see logging.json
Create a custom TelemetryConverter (subclass from TraceTelemetryConverter or EventTelemetryConverter) for ApplicationInsights that would set telemetry.Context.Operation.Id from value set in 1) - see OperationTelemetryConverter
Check out my blog post "Serilog with ApplicationInsights" that explains the points above with more details, and links
Also, be sure to take a look at Telemetry correlation in Application Insights on MSDN
If you are using ILogger in .Net core for logging purposes, those message can be directed to Application Insights with the following modification of startup.cs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
/*...existing code..*/
loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Warning);
}
If you employ your own correlation ID, you can modify Application Insights correlation IDs accordingly in Context.Operation field of telemetry item with your own Telemetry Initializer or pass those values in the respective headers (Request-ID (global ID) and Correlation-Context (name-value pairs)) in the requests to this app - AI will pick up correlation IDs from those.
The end to end transaction is supposed to be displayed together (Requests/Dependencies and Exceptions) on a timeline in the details view of Application Insights telemetry. With you own correlation IDs it should work as well if they are in there from the very beginning of transaction (e.g. in the first component) - otherwise injecting them in the middle will break the chain.

How to properly configure Spring Datasource for an Elastic Beanstalk app?

I'm running into an issue integrating Spring Security with my Elastic Beanstalk app backed by a MySql database. If I deploy my app I'm able to login in correctly for some time but eventually I'll start to receive login errors without an exception being thrown so I'm unable to get any useful information about the issue. I've downloaded the logs as well and can't see anything of value. I can see where the logs show accessing the public page, attempting to access the private section, returning the login page, and then the loginError page; however, nothing about any issue.
Even though I'm unable to login through a browser I am able to login if I run the app from an IDE as well as view the db in MySQL Workbench. This suggests to me the problem is due to some persistent state on the server.
I've had a similar problem before with another Beanstalk app using Spring Security and was able to resolve it by setting application properties as follows:
spring.datasource.test-on-borrow=true
spring.datasource.validation-query=SELECT 1
I'm using a more recent version of Spring than that app and the properties have been changed to specific datasources so I tried adding the following properties:
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.validation-query=SELECT 1
When that didn't work I added another based on an answer to a similar question here; now the properties are:
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.test-while-idle=true
spring.datasource.tomcat.validation-query=SELECT 1
That seemed to work (possibly due to less login activity) but eventually resulted in the same behavior .
I've looked into the various properties available but before I spend a lot of time randomly setting and/or overriding default settings I wanted to see if there's a reliable way to deal with this.
How can I configure my datasource to avoid login errors after long periods of time?
This isn't a problem of specific configuration values but with where those configurations reside. The default location for the application.properties (/resources; Intellij) is fine for deploying as a jar with an embedded Tomcat server but not as a war with a provided server. The file isn't found/used so no changes to the file affect the one given by AWS.
There are a number of ways to handle this; I chose to add an RDS configuration bean in my SpringBootServletInitializer:
#Bean
public RdsInstanceConfigurer instanceConfigurer() {
return () -> {
TomcatJdbcDataSourceFactory dataSourceFactory =
new TomcatJdbcDataSourceFactory();
// Abondoned connections...
dataSourceFactory.setRemoveAbandonedTimeout(60);
dataSourceFactory.setRemoveAbandoned(true);
dataSourceFactory.setLogAbandoned(true);
// Tests
dataSourceFactory.setTestOnBorrow(true);
dataSourceFactory.setTestOnReturn(false);
dataSourceFactory.setTestWhileIdle(false);
// Validations
dataSourceFactory.setValidationInterval(30000);
dataSourceFactory.setTimeBetweenEvictionRunsMillis(30000);
dataSourceFactory.setValidationQuery("SELECT 1");
return dataSourceFactory;
};
}
Below are the settings that worked for me.
From Connection to Db dies after >4<24 in spring-boot jpa hibernate
dataSourceFactory.setMaxActive(10);
dataSourceFactory.setInitialSize(10);
dataSourceFactory.setMaxIdle(10);
dataSourceFactory.setMinIdle(1);
dataSourceFactory.setTestWhileIdle(true);
dataSourceFactory.setTestOnBorrow(true);
dataSourceFactory.setValidationQuery("SELECT 1 FROM DUAL");
dataSourceFactory.setValidationInterval(10000);
dataSourceFactory.setTimeBetweenEvictionRunsMillis(20000);
dataSourceFactory.setMinEvictableIdleTimeMillis(60000);

Biztalk WCF-webhttp (WCF web publishing wizard)

[I am new in biztalk trying to publish and consume servcie using webhttp (using Biztalk 2013, VS 2012)
getting following message and don't know want to do next to solve this issue.
*you have created a service.
To test this service, you will need to create a client and use it to call the service. you can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe "http://[host]/expwebhttpsampledesktop/service1.svc?singlews"*dl
"svcutil.exe" command it generates .cs, .wsdl, and metadata.xml files for me.
not sure what i am doing wrong here but trying to consume the service i made. and at the end of it i am getting following error
"Error consuming WCF service metadata. Message part missing element. Correct service description ""http://tempuri.org/" message type "service1_operation1_inputmessage"" part "Part" and return the wizard."]
thank you in advance
You need to create a client that will now consume the service. A client can be anything from a simple Console app, a BizTalk Send Port, another Web-Service or a Winforms/WPF app. The client will invoke your service (possibly passing parameters), you service will do its stuff and return a response back to the client.
There are a number of ways to create a client, however you might want to start with this tutorial from MSDN: http://msdn.microsoft.com/en-us/library/ms733133.aspx.
Alternatively, you might want to search for 'Add Service Reference Visual Studio 2012'. Adding a service reference creates the necessary libraries for your client to consume the service.
UPDATE: I found some relevant screenshots, so I thought I would add them....
To add a Service Reference, right-click on your Project and select 'Add Service Reference':
within the 'Add Service Reference' dialog, enter the address of the service (in your case http://[host]/expwebhttpsampledesktop/service1.svc) and click 'Go' for the wizard to auto-discover the service methods. Finally, update the service Namespace:
You will now be able to reference your service just like any other type within C# in order to invoke it.
HTH, Nick.

Resources