Is it possible to set the default dispatcher for all actors in the system using only HOCON config or do I have to do:
Context.ActorOf(Props.Create<TActor>(propsArgs)
.WithDispatcher("my-fork-join-dispatcher"), actorName);
Ideally I would want to avoid having to configure this in code at all.
Default dispatcher is set up from akka.actor.default-dispatcher.type section. When you'll look into source code, you can see, how it's configured by default.
Related
We have configured RabbitMQ server to communicate with LDAP server for authentication which is working as expected. But we are facing one challenge where we need to externalize one value from configuration to environment variable.
so below is the current configuration present in advance.config file
{other_bind, {"CN=Service_Account,OU=Service Accounts,DC=XYZ,DC=com",{string,"123456"}}},
and want to make it something like this
{other_bind, {"CN=Service_Account,OU=Service Accounts,DC=XYZ,DC=com",{string,"${RABBITMQ_SERVICE_ACCOUNT_PASSWORD}"}}},
so as a result we wanted to externalize our password to some environment variable and use the same in advance.config file.
I tried setting value in rabbitmq-env.conf file but no luck.
Also as per this article we can't set a custom environment variable in rabbitmq-env.conf file, is it right? and if yes then where we can set this value?
https://riptutorial.com/rabbitmq/example/14032/configuring-rabbitmq-on--nix-systems
No, this is not supported:
{other_bind, {"CN=Service_Account,OU=Service Accounts,DC=XYZ,DC=com",{string,"${RABBITMQ_SERVICE_ACCOUNT_PASSWORD}"}}},
One option is to generate the advanced.config from a template before RabbitMQ starts. If RabbitMQ starts via systemd in your environment, you can use the ExecStartPre hook to run a custom script or program.
To create a drop-in override for the RabbitMQ systemd unit (and add ExecStartPre), follow these instructions:
https://wiki.archlinux.org/title/systemd#Editing_provided_units
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
I have a cxf endpoint configuration in my camel.xml like this:
<cxf:cxfEndpoint id="callbackInbound"
serviceClass="ch.axpo.emis.v1.timeseriesservice.Callback"
wsdlURL="wsdl/timeseries.wsdl" endpointName="tss:CallbackPort"
address="http://somehost.com:9090/CallbackService" serviceName="tss:CallbackService"/>
In one of my routes I call this endpoint like this:
.to("cxf:bean:callbackInbound?dataFormat=PAYLOAD")
So, now instead of having a fix address (http://somehost.com:9090/CallbackService) I want to be able to configure the address for different environments (DEV, TEST, PROD, ...) using system variables. This is because I use JBoss 7 as runtime environment for camel and there is a quite simple way to add system variables with JBoss.
Is there a way to do that? Or is there a better way to configure cxf endpoints in different environments?
Thanks,
Sven
You can use the properties components and define the cxfEndpoint like this
System.setProperty("environment", "junit");
<cxf:cxfEndpoint id="routerEndpoint" address="{{router.address}}"
serviceClass="org.apache.camel.component.cxf.HelloService"/>
You can define the property file just like this
router.address={{{{environment}}.router.address}}
# LOCAL SERVER
junit.router.address=junit
# LOCAL SERVER
local.router.address=local
# TEST
test.router.address=test
# PROD
prod.router.address=prod
When I update my service references it modifies the web config bindings adding a default contract to the config.
I have already specified my own generic contract to the web.config but every-time I do an Update Service reference it automatically changes what I had and places the default binding.
Anyone know how to prevent this from happening?
I can think of 2 solutions.
Create separate dll that is referencing the service and reference this dll to the main project.
Your main config wont be modified that way.
Use config transformation while compiling app.
This transformation would adapt the default configuration to your own needs.
Where can I set default config options for wcftestclient?
There are no default options. Default configuration is generated in the same way svcutil generates configuration when adding service reference. Information trasported in WSDL are used and rest of values is set to default values based on binding / behavior.
If you want to modify and reuse client config for WcfTestClient you can:
Open WcfTestClient and let it generate config for you
In Tools > Options unthick Always config when launching services. It will allow you reusing single config for subsequent WcfTestClient executions in the same project but in the same way it will not automatically modify config based on changes made in service configuration.
Edit client config with SvcConfigEditor and save it. It will saved modified config to your Documents\Test Client Projects directory. The config will be reused if your service will be executed from the same address.
I'm new to Servlet containers and have created a web application using Tomcat 6.0.26. I have 'TODO: log' scattered throughout my code. I see there exists:
myServlet.getServletContext().log()
which appears to write to a file prefixed with 'localhost' in the Tomcat '/logs' directory. I don't need any advanced logging capability, but I'd like a date, time, message and stack trace at minimum. In addition, I've created some classes used by my various servlets that need logging capabilities as well. Do I need to inject a SevletContext into these classes so they can log?
It appears that log4j from Apache is a popular logging package, but I'm not sure if it worth the trouble of setting it up.
What would be the recommended way of logging for my needs?
You don't want to tie up all your business and data access code with the ServletContext (I of course assume that your business and DB code is not tight coupled inside a servlet class, but just live in their own layer of classes, without any javax.servlet references). So I wouldn't recommend to use ServletContext#log(). It's also very seldom used in real world.
You're right that log4j is popular, even though it's been succeeded by logback. Setting up log4j doesn't need to be that troublesome. I suggest to start with a properties file which is less hard to understand than a XML file. You can always upgrade to a XML file once you understand what's going on in log4j configuration.
Create a file named log4j.properties, put it somewhere in the root of the classpath, e.g. /WEB-INF/classes (or if you're using an IDE, the root of the src folder, it will eventually land in the right place). You can also keep it outside the webapp and add its path to the server's runtime classpath by specifying its path in shared.loader property of Tomcat/conf/catalina.properties. Finally fill it as follows:
# Set root logger level and appender name.
log4j.rootLogger = TRACE, console
# Specify appenders.
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.file = org.apache.log4j.DailyRollingFileAppender
# Configure console appender.
log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern = %d{ABSOLUTE} [%t] %-5p %m%n
# Configure file appender.
log4j.appender.file.File = /webapp/logs/web.log
log4j.appender.file.DatePattern = '.'yyyy-MM-dd
log4j.appender.file.layout = org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern = %d{ABSOLUTE} [%t] %-5p %m%n
This kickoff example by default logs at a level of TRACE. You can change it to DEBUG or INFO like so:
# Set root logger level and appender name.
log4j.rootLogger = INFO, console
This example also by default uses the console appender. It will log to the standard output as it is configured by Tomcat which by default lands in the /logs/localhost.yyyy-MM-dd.log file.
You can however change it to use the file appender like so:
# Set root logger level and appender name.
log4j.rootLogger = INFO, file
The ConversionPattern settings can be found in detail in the PatternLayout javadoc.
Hope this helps to get you started.
In addition to all the stuff BalusC has mentioned above, in your java code (servlets/beans/whatever) just import and initialize the Logger
package my.app;
import org.apache.log4j.Logger;
private static Logger logger = Logger.getLogger("classname");
// use any string you want
Then at any logging point you can log at various levels like
if (logger.isDebugEnabled()) {
logger.debug("Some log at this point");
}
...
logger.info("Some info message here");
These will appear in the logs depending on whether you set DEBUG or INFO in the log4j.propeties
Take a look at the examples on http://www.java2s.com/Code/Java/Language-Basics/Examplelog4jConfigurationFile.htm and all the Related examples in the same article