text,length,is_long_context,metric_val,label_metric "= Vert.x Core Manual :toc: left At the heart of Vert.x is a set of Java APIs that we call *Vert.x Core* https://github.com/eclipse/vert.x[Repository]. Vert.x core provides functionality for things like: * Writing TCP clients and servers * Writing HTTP clients and servers including support for WebSockets * The Event bus * Shared data - local maps and clustered distributed maps * Periodic and delayed actions * Deploying and undeploying Verticles * Datagram Sockets * DNS client * File system access * High availability * Native transports * Clustering The functionality in core is fairly low level - you won't find stuff like database access, authorisation or high level web functionality here - that kind of stuff you'll find in *Vert.x ext* (extensions). Vert.x core is small and lightweight. You just use the parts you want. It's also entirely embeddable in your existing applications - we don't force you to structure your applications in a special way just so you can use Vert.x. You can use core from any of the other languages that Vert.x supports. But here'a a cool bit - we don't force you to use the Java API directly from, say, JavaScript or Ruby - after all, different languages have different conventions and idioms, and it would be odd to force Java idioms on Ruby developers (for example). Instead, we automatically generate an *idiomatic* equivalent of the core Java APIs for each language. From now on we'll just use the word *core* to refer to Vert.x core. include::override/dependencies.adoc[] Let's discuss the different concepts and features in core. == In the beginning there was Vert.x //// TODO Much of this is Java specific - need someway of swapping in language specific parts //// You can't do much in Vert.x-land unless you can communicate with a {@link io.vertx.core.Vertx} object! It's the control centre of Vert.x and is how you do pretty much everything, including creating clients and servers, getting a reference to the event bus, setting timers, as well as many other things. So how do you get an instance? If you're embedding Vert.x then you simply create an instance as follows: [source,$lang] ---- {@link examples.CoreExamples#example1} ---- NOTE: Most applications will only need a single Vert.x instance, but it's possible to create multiple Vert.x instances if you require, for example, isolation between the event bus or different groups of servers and clients. === Specifying options when creating a Vertx object When creating a Vertx object you can also specify options if the defaults aren't right for you: [source,$lang] ---- {@link examples.CoreExamples#example2} ---- The {@link io.vertx.core.VertxOptions} object has many settings and allows you to configure things like clustering, high availability, pool sizes and various other settings. The Javadoc describes all the settings in detail. === Creating a clustered Vert.x object If you're creating a *clustered Vert.x* (See the section on the <> for more information on clustering the event bus), then you will normally use the asynchronous variant to create the Vertx object. This is because it usually takes some time (maybe a few seconds) for the different Vert.x instances in a cluster to group together. During that time, we don't want to block the calling thread, so we give the result to you asynchronously. == Are you fluent? You may have noticed that in the previous examples a *fluent* API was used. A fluent API is where multiple methods calls can be chained together. For example: [source,$lang] ---- {@link examples.CoreExamples#example3} ---- This is a common pattern throughout Vert.x APIs, so get used to it. Chaining calls like this allows you to write code that's a little bit less verbose. Of course, if you don't like the fluent approach *we don't force you* to do it that way, you can happily ignore it if you prefer and write your code like this: [source,$lang] ---- {@link examples.CoreExamples#example4} ---- == Don't call us, we'll call you. The Vert.x APIs are largely _event driven_. This means that when things happen in Vert.x that you are interested in, Vert.x will call you by sending you events. Some example events are: * a timer has fired * some data has arrived on a socket, * some data has been read from disk * an exception has occurred * an HTTP server has received a request You handle events by providing _handlers_ to the Vert.x APIs. For example to receive a timer event every second you would do: [source,$lang] ---- {@link examples.CoreExamples#example5} ---- Or to receive an HTTP request: [source,$lang] ---- {@link examples.CoreExamples#example6} ---- Some time later when Vert.x has an event to pass to your handler Vert.x will call it *asynchronously*. This leads us to some important concepts in Vert.x: == Don't block me! With very few exceptions (i.e. some file system operations ending in 'Sync'), none of the APIs in Vert.x block the calling thread. If a result can be provided immediately, it will be returned immediately, otherwise you will usually provide a handler to receive events some time later. Because none of the Vert.x APIs block threads that means you can use Vert.x to handle a lot of concurrency using just a small number of threads. With a conventional blocking API the calling thread might block when: * Reading data from a socket * Writing data to disk * Sending a message to a recipient and waiting for a reply. * ... Many other situations In all the above cases, when your thread is waiting for a result it can't do anything else - it's effectively useless. This means that if you want a lot of concurrency using blocking APIs then you need a lot of threads to prevent your application grinding to a halt. Threads have overhead in terms of the memory they require (e.g. for their stack) and in context switching. For the levels of concurrency required in many modern applications, a blocking approach just doesn't scale. == Reactor and Multi-Reactor We mentioned before that Vert.x APIs are event driven - Vert.x passes events to handlers when they are available. In most cases Vert.x calls your handlers using a thread called an *event loop*. As nothing in Vert.x or your application blocks, the event loop can merrily run around delivering events to different handlers in succession as they arrive. Because nothing blocks, an event loop can potentially deliver huge amounts of events in a short amount of time. For example a single event loop can handle many thousands of HTTP requests very quickly. We call this the http://en.wikipedia.org/wiki/Reactor_pattern[Reactor Pattern]. You may have heard of this before - for example Node.js implements this pattern. In a standard reactor implementation there is a *single event loop* thread which runs around in a loop delivering all events to all handlers as they arrive. The trouble with a single thread is it can only run on a single core at any one time, so if you want your single threaded reactor application (e.g. your Node.js application) to scale over your multi-core server you have to start up and manage many different processes. Vert.x works differently here. Instead of a single event loop, each Vertx instance maintains *several event loops*. By default we choose the number based on the number of available cores on the machine, but this can be overridden. This means a single Vertx process can scale across your server, unlike Node.js. We call this pattern the *Multi-Reactor Pattern* to distinguish it from the single threaded reactor pattern. NOTE: Even though a Vertx instance maintains multiple event loops, any particular handler will never be executed concurrently, and in most cases (with the exception of <>) will always be called using the *exact same event loop*. [[golden_rule]] == The Golden Rule - Don't Block the Event Loop We already know that the Vert.x APIs are non blocking and won't block the event loop, but that's not much help if you block the event loop *yourself* in a handler. If you do that, then that event loop will not be able to do anything else while it's blocked. If you block all of the event loops in Vertx instance then your application will grind to a complete halt! So don't do it! *You have been warned*. Examples of blocking include: * +Thread.sleep()+ * Waiting on a lock * Waiting on a mutex or monitor (e.g. synchronized section) * Doing a long lived database operation and waiting for a result * Doing a complex calculation that takes some significant time. * Spinning in a loop If any of the above stop the event loop from doing anything else for a *significant amount of time* then you should go immediately to the naughty step, and await further instructions. So... what is a *significant amount of time*? How long is a piece of string? It really depends on your application and the amount of concurrency you require. If you have a single event loop, and you want to handle 10000 http requests per second, then it's clear that each request can't take more than 0.1 ms to process, so you can't block for any more time than that. *The maths is not hard and shall be left as an exercise for the reader.* If your application is not responsive it might be a sign that you are blocking an event loop somewhere. To help you diagnose such issues, Vert.x will automatically log warnings if it detects an event loop hasn't returned for some time. If you see warnings like these in your logs, then you should investigate. ---- Thread vertx-eventloop-thread-3 has been blocked for 20458 ms ---- Vert.x will also provide stack traces to pinpoint exactly where the blocking is occurring. If you want to turn off these warnings or change the settings, you can do that in the {@link io.vertx.core.VertxOptions} object before creating the Vertx object. [[blocking_code]] == Running blocking code In a perfect world, there will be no war or hunger, all APIs will be written asynchronously and bunny rabbits will skip hand-in-hand with baby lambs across sunny green meadows. *But... the real world is not like that. (Have you watched the news lately?)* Fact is, many, if not most libraries, especially in the JVM ecosystem have synchronous APIs and many of the methods are likely to block. A good example is the JDBC API - it's inherently synchronous, and no matter how hard it tries, Vert.x cannot sprinkle magic pixie dust on it to make it asynchronous. We're not going to rewrite everything to be asynchronous overnight so we need to provide you a way to use ""traditional"" blocking APIs safely within a Vert.x application. As discussed before, you can't call blocking operations directly from an event loop, as that would prevent it from doing any other useful work. So how can you do this? It's done by calling {@link io.vertx.core.Vertx#executeBlocking} specifying both the blocking code to execute and a result handler to be called back asynchronous when the blocking code has been executed. [source,$lang] ---- {@link examples.CoreExamples#example7} ---- By default, if executeBlocking is called several times from the same context (e.g. the same verticle instance) then the different executeBlocking are executed _serially_ (i.e. one after another). If you don't care about ordering you can call {@link io.vertx.core.Vertx#executeBlocking(io.vertx.core.Handler,boolean,io.vertx.core.Handler)} specifying `false` as the argument to `ordered`. In this case any executeBlocking may be executed in parallel on the worker pool. An alternative way to run blocking code is to use a <> A worker verticle is always executed with a thread from the worker pool. By default blocking code is executed on the Vert.x worker pool, configured with {@link io.vertx.core.VertxOptions#setWorkerPoolSize(int)}. Additional pools can be created for different purposes: [source,$lang] ---- {@link examples.CoreExamples#workerExecutor1} ---- The worker executor must be closed when it's not necessary anymore: [source,$lang] ---- {@link examples.CoreExamples#workerExecutor2} ---- When several workers are created with the same name, they will share the same pool. The worker pool is destroyed when all the worker executors using it are closed. When an executor is created in a Verticle, Vert.x will close it automatically for you when the Verticle is undeployed. Worker executors can be configured when created: [source,$lang] ---- {@link examples.CoreExamples#workerExecutor3} ---- NOTE: the configuration is set when the worker pool is created == Async coordination Coordination of multiple asynchronous results can be achieved with Vert.x {@link io.vertx.core.Future futures}. It supports concurrent composition (run several async operations in parallel) and sequential composition (chain async operations). === Concurrent composition {@link io.vertx.core.CompositeFuture#all} takes several futures arguments (up to 6) and returns a future that is _succeeded_ when all the futures are and _failed_ when at least one of the futures is failed: [source,$lang] ---- {@link examples.CoreExamples#exampleFutureAll1} ---- The operations run concurrently, the {@link io.vertx.core.Handler} attached to the returned future is invoked upon completion of the composition. When one of the operation fails (one of the passed future is marked as a failure), the resulting future is marked as failed too. When all the operations succeed, the resulting future is completed with a success. Alternatively, you can pass a list (potentially empty) of futures: [source,$lang] ---- {@link examples.CoreExamples#exampleFutureAll2} ---- While the `all` composition _waits_ until all futures are successful (or one fails), the `any` composition _waits_ for the first succeeded future. {@link io.vertx.core.CompositeFuture#any} takes several futures arguments (up to 6) and returns a future that is succeeded when one of the futures is, and failed when all the futures are failed: [source,$lang] ---- {@link examples.CoreExamples#exampleFutureAny1} ---- A list of futures can be used also: [source,$lang] ---- {@link examples.CoreExamples#exampleFutureAny2} ---- The `join` composition _waits_ until all futures are completed, either with a success or a failure. {@link io.vertx.core.CompositeFuture#join} takes several futures arguments (up to 6) and returns a future that is succeeded when all the futures are succeeded, and failed when all the futures are completed and at least one of them is failed: [source,$lang] ---- {@link examples.CoreExamples#exampleFutureJoin1} ---- A list of futures can be used also: [source,$lang] ---- {@link examples.CoreExamples#exampleFutureJoin2} ---- === Sequential composition While `all` and `any` are implementing concurrent composition, {@link io.vertx.core.Future#compose} can be used for chaining futures (so sequential composition). [source,$lang] ---- {@link examples.CoreExamples#exampleFuture6} ---- In this example, 3 operations are chained: 1. a file is created (`fut1`) 2. something is written in the file (`fut2`) 3. the file is moved (`startFuture`) When these 3 steps are successful, the final future (`startFuture`) is succeeded. However, if one of the steps fails, the final future is failed. This example uses: * {@link io.vertx.core.Future#compose(java.util.function.Function)}: when the current future completes, run the given function, that returns a future. When this returned future completes, it completes the composition. * {@link io.vertx.core.Future#compose(io.vertx.core.Handler,io.vertx.core.Future)}: when the current future completes, run the given handler that completes the given `future` (next). In this second case, the {@link io.vertx.core.Handler} should complete the `next` future to report its success or failure. You can use {@link io.vertx.core.Future#completer()} that completes a future with the operation result or failure. It avoids having to write the _traditional_: `if success then complete the future else fail the future`. == Verticles Vert.x comes with a simple, scalable, _actor-like_ deployment and concurrency model out of the box that you can use to save you writing your own. *This model is entirely optional and Vert.x does not force you to create your applications in this way if you don't want to.*. The model does not claim to be a strict actor-model implementation, but it does share similarities especially with respect to concurrency, scaling and deployment. To use this model, you write your code as set of *verticles*. Verticles are chunks of code that get deployed and run by Vert.x. A Vert.x instance maintains N event loop threads (where N by default is core*2) by default. Verticles can be written in any of the languages that Vert.x supports and a single application can include verticles written in multiple languages. You can think of a verticle as a bit like an actor in the http://en.wikipedia.org/wiki/Actor_model[Actor Model]. An application would typically be composed of many verticle instances running in the same Vert.x instance at the same time. The different verticle instances communicate with each other by sending messages on the <>. include::override/verticles.adoc[] === Verticle Types There are three different types of verticles: Standard Verticles:: These are the most common and useful type - they are always executed using an event loop thread. We'll discuss this more in the next section. Worker Verticles:: These run using a thread from the worker pool. An instance is never executed concurrently by more than one thread. Multi-threaded worker verticles:: These run using a thread from the worker pool. An instance can be executed concurrently by more than one thread. === Standard verticles Standard verticles are assigned an event loop thread when they are created and the +start+ method is called with that event loop. When you call any other methods that takes a handler on a core API from an event loop then Vert.x will guarantee that those handlers, when called, will be executed on the same event loop. This means we can guarantee that all the code in your verticle instance is always executed on the same event loop (as long as you don't create your own threads and call it!). This means you can write all the code in your application as single threaded and let Vert.x worry about the threading and scaling. No more worrying about +synchronized+ and +volatile+ any more, and you also avoid many other cases of race conditions and deadlock so prevalent when doing hand-rolled 'traditional' multi-threaded application development. [[worker_verticles]] === Worker verticles A worker verticle is just like a standard verticle but it's executed using a thread from the Vert.x worker thread pool, rather than using an event loop. Worker verticles are designed for calling blocking code, as they won't block any event loops. If you don't want to use a worker verticle to run blocking code, you can also run <> directly while on an event loop. If you want to deploy a verticle as a worker verticle you do that with {@link io.vertx.core.DeploymentOptions#setWorker}. [source,$lang] ---- {@link examples.CoreExamples#example7_1} ---- Worker verticle instances are never executed concurrently by Vert.x by more than one thread, but can executed by different threads at different times. ==== Multi-threaded worker verticles A multi-threaded worker verticle is just like a normal worker verticle but it *can* be executed concurrently by different threads. WARNING: Multi-threaded worker verticles are an advanced feature and most applications will have no need for them. Because of the concurrency in these verticles you have to be very careful to keep the verticle in a consistent state using standard Java techniques for multi-threaded programming. === Deploying verticles programmatically You can deploy a verticle using one of the {@link io.vertx.core.Vertx#deployVerticle} method, specifying a verticle name or you can pass in a verticle instance you have already created yourself. NOTE: Deploying Verticle *instances* is Java only. [source,java] ---- {@link examples.CoreExamples#example8} ---- You can also deploy verticles by specifying the verticle *name*. The verticle name is used to look up the specific {@link io.vertx.core.spi.VerticleFactory} that will be used to instantiate the actual verticle instance(s). Different verticle factories are available for instantiating verticles in different languages and for various other reasons such as loading services and getting verticles from Maven at run-time. This allows you to deploy verticles written in any language from any other language that Vert.x supports. Here's an example of deploying some different types of verticles: [source,$lang] ---- {@link examples.CoreExamples#example9} ---- === Rules for mapping a verticle name to a verticle factory When deploying verticle(s) using a name, the name is used to select the actual verticle factory that will instantiate the verticle(s). Verticle names can have a prefix - which is a string followed by a colon, which if present will be used to look-up the factory, e.g. js:foo.js // Use the JavaScript verticle factory groovy:com.mycompany.SomeGroovyCompiledVerticle // Use the Groovy verticle factory service:com.mycompany:myorderservice // Uses the service verticle factory If no prefix is present, Vert.x will look for a suffix and use that to lookup the factory, e.g. foo.js // Will also use the JavaScript verticle factory SomeScript.groovy // Will use the Groovy verticle factory If no prefix or suffix is present, Vert.x will assume it's a Java fully qualified class name (FQCN) and try and instantiate that. === How are Verticle Factories located? Most Verticle factories are loaded from the classpath and registered at Vert.x startup. You can also programmatically register and unregister verticle factories using {@link io.vertx.core.Vertx#registerVerticleFactory} and {@link io.vertx.core.Vertx#unregisterVerticleFactory} if you wish. === Waiting for deployment to complete Verticle deployment is asynchronous and may complete some time after the call to deploy has returned. If you want to be notified when deployment is complete you can deploy specifying a completion handler: [source,$lang] ---- {@link examples.CoreExamples#example10} ---- The completion handler will be passed a result containing the deployment ID string, if deployment succeeded. This deployment ID can be used later if you want to undeploy the deployment. === Undeploying verticle deployments Deployments can be undeployed with {@link io.vertx.core.Vertx#undeploy}. Un-deployment is itself asynchronous so if you want to be notified when un-deployment is complete you can deploy specifying a completion handler: [source,$lang] ---- {@link examples.CoreExamples#example11} ---- === Specifying number of verticle instances When deploying a verticle using a verticle name, you can specify the number of verticle instances that you want to deploy: [source,$lang] ---- {@link examples.CoreExamples#example12} ---- This is useful for scaling easily across multiple cores. For example you might have a web-server verticle to deploy and multiple cores on your machine, so you want to deploy multiple instances to utilise all the cores. include::override/verticle-configuration.adoc[] === Verticle Isolation Groups By default, Vert.x has a _flat classpath_. I.e, when Vert.x deploys verticles it does so with the current classloader - it doesn't create a new one. In the majority of cases this is the simplest, clearest, and sanest thing to do. However, in some cases you may want to deploy a verticle so the classes of that verticle are isolated from others in your application. This might be the case, for example, if you want to deploy two different versions of a verticle with the same class name in the same Vert.x instance, or if you have two different verticles which use different versions of the same jar library. When using an isolation group you provide a list of the class names that you want isolated using {@link io.vertx.core.DeploymentOptions#setIsolatedClasses(java.util.List)}- an entry can be a fully qualified classname such as `com.mycompany.myproject.engine.MyClass` or it can be a wildcard which will match any classes in a package and any sub-packages, e.g. `com.mycompany.myproject.*` would match any classes in the package `com.mycompany.myproject` or any sub-packages. Please note that _only_ the classes that match will be isolated - any other classes will be loaded by the current class loader. Extra classpath entries can also be provided with {@link io.vertx.core.DeploymentOptions#setExtraClasspath} so if you want to load classes or resources that aren't already present on the main classpath you can add this. WARNING: Use this feature with caution. Class-loaders can be a can of worms, and can make debugging difficult, amongst other things. Here's an example of using an isolation group to isolate a verticle deployment. [source,$lang] ---- {@link examples.CoreExamples#example14} ---- === High Availability Verticles can be deployed with High Availability (HA) enabled. In that context, when a verticle is deployed on a vert.x instance that dies abruptly, the verticle is redeployed on another vert.x instance from the cluster. To run an verticle with the high availability enabled, just append the `-ha` switch: [source] ---- vertx run my-verticle.js -ha ---- When enabling high availability, no need to add `-cluster`. More details about the high availability feature and configuration in the <> section. === Running Verticles from the command line You can use Vert.x directly in your Maven or Gradle projects in the normal way by adding a dependency to the Vert.x core library and hacking from there. However you can also run Vert.x verticles directly from the command line if you wish. To do this you need to download and install a Vert.x distribution, and add the `bin` directory of the installation to your `PATH` environment variable. Also make sure you have a Java 8 JDK on your `PATH`. NOTE: The JDK is required to support on the fly compilation of Java code. You can now run verticles by using the `vertx run` command. Here are some examples: ---- # Run a JavaScript verticle vertx run my_verticle.js # Run a Ruby verticle vertx run a_n_other_verticle.rb # Run a Groovy script verticle, clustered vertx run FooVerticle.groovy -cluster ---- You can even run Java source verticles without compiling them first! ---- vertx run SomeJavaSourceFile.java ---- Vert.x will compile the Java source file on the fly before running it. This is really useful for quickly prototyping verticles and great for demos. No need to set-up a Maven or Gradle build first to get going! For full information on the various options available when executing `vertx` on the command line, type `vertx` at the command line. === Causing Vert.x to exit Threads maintained by Vert.x instances are not daemon threads so they will prevent the JVM from exiting. If you are embedding Vert.x and you have finished with it, you can call {@link io.vertx.core.Vertx#close} to close it down. This will shut-down all internal thread pools and close other resources, and will allow the JVM to exit. === The Context object When Vert.x provides an event to a handler or calls the start or stop methods of a {@link io.vertx.core.Verticle}, the execution is associated with a `Context`. Usually a context is an *event-loop context* and is tied to a specific event loop thread. So executions for that context always occur on that exact same event loop thread. In the case of worker verticles and running inline blocking code a worker context will be associated with the execution which will use a thread from the worker thread pool. To retrieve the context, use the {@link io.vertx.core.Vertx#getOrCreateContext()} method: [source, $lang] ---- {@link examples.CoreExamples#retrieveContext(io.vertx.core.Vertx)} ---- If the current thread has a context associated with it, it reuses the context object. If not a new instance of context is created. You can test the _type_ of context you have retrieved: [source, $lang] ---- {@link examples.CoreExamples#retrieveContextType(io.vertx.core.Vertx)} ---- When you have retrieved the context object, you can run code in this context asynchronously. In other words, you submit a task that will be eventually run in the same context, but later: [source, $lang] ---- {@link examples.CoreExamples#runInContext(io.vertx.core.Vertx)} ---- When several handlers run in the same context, they may want to share data. The context object offers methods to store and retrieve data shared in the context. For instance, it lets you pass data to some action run with {@link io.vertx.core.Context#runOnContext(io.vertx.core.Handler)}: [source, $lang] ---- {@link examples.CoreExamples#runInContextWithData(io.vertx.core.Vertx)} ---- The context object also let you access verticle configuration using the {@link io.vertx.core.Context#config()} method. Check the <> section for more details about this configuration. === Executing periodic and delayed actions It's very common in Vert.x to want to perform an action after a delay, or periodically. In standard verticles you can't just make the thread sleep to introduce a delay, as that will block the event loop thread. Instead you use Vert.x timers. Timers can be *one-shot* or *periodic*. We'll discuss both ==== One-shot Timers A one shot timer calls an event handler after a certain delay, expressed in milliseconds. To set a timer to fire once you use {@link io.vertx.core.Vertx#setTimer} method passing in the delay and a handler [source,$lang] ---- {@link examples.CoreExamples#example15} ---- The return value is a unique timer id which can later be used to cancel the timer. The handler is also passed the timer id. ==== Periodic Timers You can also set a timer to fire periodically by using {@link io.vertx.core.Vertx#setPeriodic}. There will be an initial delay equal to the period. The return value of `setPeriodic` is a unique timer id (long). This can be later used if the timer needs to be cancelled. The argument passed into the timer event handler is also the unique timer id: Keep in mind that the timer will fire on a periodic basis. If your periodic treatment takes a long amount of time to proceed, your timer events could run continuously or even worse : stack up. In this case, you should consider using {@link io.vertx.core.Vertx#setTimer} instead. Once your treatment has finished, you can set the next timer. [source,$lang] ---- {@link examples.CoreExamples#example16} ---- ==== Cancelling timers To cancel a periodic timer, call {@link io.vertx.core.Vertx#cancelTimer} specifying the timer id. For example: [source,$lang] ---- {@link examples.CoreExamples#example17} ---- ==== Automatic clean-up in verticles If you're creating timers from inside verticles, those timers will be automatically closed when the verticle is undeployed. === Verticle worker pool Verticles use the Vert.x worker pool for executing blocking actions, i.e {@link io.vertx.core.Context#executeBlocking} or worker verticle. A different worker pool can be specified in deployment options: [source,$lang] ---- {@link examples.CoreExamples#deployVerticleWithDifferentWorkerPool} ---- [[event_bus]] include::eventbus.adoc[] include::override/json.adoc[] include::buffers.adoc[] include::net.adoc[] include::http.adoc[] include::shareddata.adoc[] include::filesystem.adoc[] include::datagrams.adoc[] include::dns.adoc[] [[streams]] include::streams.adoc[] include::parsetools.adoc[] == Thread safety Most Vert.x objects are safe to access from different threads. _However_ performance is optimised when they are accessed from the same context they were created from. For example if you have deployed a verticle which creates a {@link io.vertx.core.net.NetServer} which provides {@link io.vertx.core.net.NetSocket} instances in it's handler, then it's best to always access that socket instance from the event loop of the verticle. If you stick to the standard Vert.x verticle deployment model and avoid sharing objects between verticles then this should be the case without you having to think about it. == Metrics SPI By default Vert.x does not record any metrics. Instead it provides an SPI for others to implement which can be added to the classpath. The metrics SPI is an advanced feature which allows implementers to capture events from Vert.x in order to gather metrics. For more information on this, please consult the {@link io.vertx.core.spi.metrics.VertxMetrics API Documentation}. You can also specify a metrics factory programmatically if embedding Vert.x using {@link io.vertx.core.metrics.MetricsOptions#setFactory(io.vertx.core.spi.VertxMetricsFactory)}. == OSGi Vert.x Core is packaged as an OSGi bundle, so can be used in any OSGi R4.2+ environment such as Apache Felix or Eclipse Equinox. The bundle exports `io.vertx.core*`. However, the bundle has some dependencies on Jackson and Netty. To get the vert.x core bundle resolved deploy: * Jackson Annotation [2.6.0,3) * Jackson Core [2.6.2,3) * Jackson Databind [2.6.2,3) * Netty Buffer [4.0.31,5) * Netty Codec [4.0.31,5) * Netty Codec/Socks [4.0.31,5) * Netty Codec/Common [4.0.31,5) * Netty Codec/Handler [4.0.31,5) * Netty Codec/Transport [4.0.31,5) Here is a working deployment on Apache Felix 5.2.0: [source] ---- 14|Active | 1|Jackson-annotations (2.6.0) 15|Active | 1|Jackson-core (2.6.2) 16|Active | 1|jackson-databind (2.6.2) 18|Active | 1|Netty/Buffer (4.0.31.Final) 19|Active | 1|Netty/Codec (4.0.31.Final) 20|Active | 1|Netty/Codec/HTTP (4.0.31.Final) 21|Active | 1|Netty/Codec/Socks (4.0.31.Final) 22|Active | 1|Netty/Common (4.0.31.Final) 23|Active | 1|Netty/Handler (4.0.31.Final) 24|Active | 1|Netty/Transport (4.0.31.Final) 25|Active | 1|Netty/Transport/SCTP (4.0.31.Final) 26|Active | 1|Vert.x Core (3.1.0) ---- On Equinox, you may want to disable the `ContextFinder` with the following framework property: `eclipse.bundle.setTCCL=false` == The 'vertx' command line The `vertx` command is used to interact with Vert.x from the command line. It's main use is to run Vert.x verticles. To do this you need to download and install a Vert.x distribution, and add the `bin` directory of the installation to your `PATH` environment variable. Also make sure you have a Java 8 JDK on your `PATH`. NOTE: The JDK is required to support on the fly compilation of Java code. === Run verticles You can run raw Vert.x verticles directly from the command line using `vertx run`. Here is a couple of examples of the `run` _command_: [source] ---- vertx run my-verticle.js (1) vertx run my-verticle.groovy (2) vertx run my-verticle.rb (3) vertx run io.vertx.example.MyVerticle (4) vertx run io.vertx.example.MVerticle -cp my-verticle.jar (5) vertx run MyVerticle.java (6) ---- 1. Deploys a JavaScript verticle 2. Deploys a Groovy verticle 3. Deploys a Ruby verticle 4. Deploys an already compiled Java verticle. Classpath root is the current directory 5. Deploys a verticle packaged in a Jar, the jar need to be in the classpath 6. Compiles the Java source and deploys it As you can see in the case of Java, the name can either be the fully qualified class name of the verticle, or you can specify the Java Source file directly and Vert.x compiles it for you. You can also prefix the verticle with the name of the language implementation to use. For example if the verticle is a compiled Groovy class, you prefix it with `groovy:` so that Vert.x knows it's a Groovy class not a Java class. [source] ---- vertx run groovy:io.vertx.example.MyGroovyVerticle ---- The `vertx run` command can take a few optional parameters, they are: * `-conf ` - Provides some configuration to the verticle. `config_file` is the name of a text file containing a JSON object that represents the configuration for the verticle. This is optional. * `-cp ` - The path on which to search for the verticle and any other resources used by the verticle. This defaults to `.` (current directory). If your verticle references other scripts, classes or other resources (e.g. jar files) then make sure these are on this path. The path can contain multiple path entries separated by `:` (colon) or `;` (semi-colon) depending on the operating system. Each path entry can be an absolute or relative path to a directory containing scripts, or absolute or relative filenames for jar or zip files. An example path might be `-cp classes:lib/otherscripts:jars/myjar.jar:jars/otherjar.jar`. Always use the path to reference any resources that your verticle requires. Do **not** put them on the system classpath as this can cause isolation issues between deployed verticles. * `-instances ` - The number of instances of the verticle to instantiate. Each verticle instance is strictly single threaded so to scale your application across available cores you might want to deploy more than one instance. If omitted a single instance will be deployed. * `-worker` - This option determines whether the verticle is a worker verticle or not. * `-cluster` - This option determines whether the Vert.x instance will attempt to form a cluster with other Vert.x instances on the network. Clustering Vert.x instances allows Vert.x to form a distributed event bus with other nodes. Default is `false` (not clustered). * `-cluster-port` - If the cluster option has also been specified then this determines which port will be used for cluster communication with other Vert.x instances. Default is `0` - which means '_choose a free random port_'. You don't usually need to specify this parameter unless you really need to bind to a specific port. * `-cluster-host` - If the cluster option has also been specified then this determines which host address will be used for cluster communication with other Vert.x instances. By default it will try and pick one from the available interfaces. If you have more than one interface and you want to use a specific one, specify it here. * `-ha` - if specified the verticle will be deployed as high availability (HA) deployment. See related section for more details * `-quorum` - used in conjunction with `-ha`. It specifies the minimum number of nodes in the cluster for any _HA deploymentIDs_ to be active. Defaults to 0. * `-hagroup` - used in conjunction with `-ha`. It specifies the HA group this node will join. There can be multiple HA groups in a cluster. Nodes will only failover to other nodes in the same group. The default value is ` +++__DEFAULT__+++` You can also set system properties using: `-Dkey=value`. Here are some more examples: Run a JavaScript verticle server.js with default settings [source] ---- vertx run server.js ---- Run 10 instances of a pre-compiled Java verticle specifying classpath [source] ---- vertx run com.acme.MyVerticle -cp ""classes:lib/myjar.jar"" -instances 10 ---- Run 10 instances of a Java verticle by source _file_ [source] ---- vertx run MyVerticle.java -instances 10 ---- Run 20 instances of a ruby worker verticle [source] ---- vertx run order_worker.rb -instances 20 -worker ---- Run two JavaScript verticles on the same machine and let them cluster together with each other and any other servers on the network [source] ---- vertx run handler.js -cluster vertx run sender.js -cluster ---- Run a Ruby verticle passing it some config [source] ---- vertx run my_verticle.rb -conf my_verticle.conf ---- Where `my_verticle.conf` might contain something like: [source, json] ---- { ""name"": ""foo"", ""num_widgets"": 46 } ---- The config will be available inside the verticle via the core API. When using the high-availability feature of vert.x you may want to create a _bare_ instance of vert.x. This instance does not deploy any verticles when launched, but will receive a verticle if another node of the cluster dies. To create a _bare_ instance, launch: [source] ---- vertx bare ---- Depending on your cluster configuration, you may have to append the `cluster-host` and `cluster-port` parameters. === Executing a Vert.x application packaged as a fat jar A _fat jar_ is an executable jar embedding its dependencies. This means you don't have to have Vert.x pre-installed on the machine on which you execute the jar. Like any executable Java jar it can be executed with. [source] ---- java -jar my-application-fat.jar ---- There is nothing really Vert.x specific about this, you could do this with any Java application You can either create your own main class and specify that in the manifest, but it's recommended that you write your code as verticles and use the Vert.x {@link io.vertx.core.Launcher} class (`io.vertx.core.Launcher`) as your main class. This is the same main class used when running Vert.x at the command line and therefore allows you to specify command line arguments, such as `-instances` in order to scale your application more easily. To deploy your verticle in a _fatjar_ like this you must have a _manifest_ with: * `Main-Class` set to `io.vertx.core.Launcher` * `Main-Verticle` specifying the main verticle (fully qualified class name or script file name) You can also provide the usual command line arguments that you would pass to `vertx run`: [source] ---- java -jar my-verticle-fat.jar -cluster -conf myconf.json java -jar my-verticle-fat.jar -cluster -conf myconf.json -cp path/to/dir/conf/cluster_xml ---- NOTE: Please consult the Maven/Gradle simplest and Maven/Gradle verticle examples in the examples repository for examples of building applications as fatjars. A fat jar executes the `run` command, by default. === Displaying version of Vert.x To display the vert.x version, just launch: [source] ---- vertx version ---- === Other commands The `vertx` command line and the `Launcher` also provide other _commands_ in addition to `run` and `version`: You can create a `bare` instance using: [source] ---- vertx bare # or java -jar my-verticle-fat.jar bare ---- You can also start an application in background using: [source] ---- java -jar my-verticle-fat.jar start --vertx-id=my-app-name ---- If `my-app-name` is not set, a random id will be generated, and printed on the command prompt. You can pass `run` options to the `start` command: [source] ---- java -jar my-verticle-fat.jar start —-vertx-id=my-app-name -cluster ---- Once launched in background, you can stop it with the `stop` command: [source] ---- java -jar my-verticle-fat.jar stop my-app-name ---- You can also list the vert.x application launched in background using: [source] ---- java -jar my-verticle-fat.jar list ---- The `start`, `stop` and `list` command are also available from the `vertx` tool. The start` command supports a couple of options: * `vertx-id` : the application id, uses a random UUID if not set * `java-opts` : the Java Virtual Machine options, uses the `JAVA_OPTS` environment variable if not set. * `redirect-output` : redirect the spawned process output and error streams to the parent process streams. If option values contain spaces, don't forget to wrap the value between {@code """"} (double-quotes). As the `start` command spawns a new process, the java options passed to the JVM are not propagated, so you **must** use `java-opts` to configure the JVM (`-X`, `-D`...). If you use the `CLASSPATH` environment variable, be sure it contains all the required jars (vertx-core, your jars and all the dependencies). The set of commands is extensible, refer to the <> section. === Live Redeploy When developing it may be convenient to automatically redeploy your application upon file changes. The `vertx` command line tool and more generally the {@link io.vertx.core.Launcher} class offers this feature. Here are some examples: [source] ---- vertx run MyVerticle.groovy --redeploy=""**/*.groovy"" --launcher-class=io.vertx.core.Launcher vertx run MyVerticle.groovy --redeploy=""**/*.groovy,**/*.rb"" --launcher-class=io.vertx.core.Launcher java io.vertx.core.Launcher run org.acme.MyVerticle --redeploy=""**/*.class"" --launcher-class=io.vertx.core .Launcher -cp ... ---- The redeployment process is implemented as follows. First your application is launched as a background application (with the `start` command). On matching file changes, the process is stopped and the application is restarted. This avoids leaks, as the process is restarted. To enable the live redeploy, pass the `--redeploy` option to the `run` command. The `--redeploy` indicates the set of file to _watch_. This set can use Ant-style patterns (with `\\**`, `*` and `?`). You can specify several sets by separating them using a comma (`,`). Patterns are relative to the current working directory. Parameters passed to the `run` command are passed to the application. Java Virtual Machine options can be configured using `--java-opts`. For instance, to pass the the `conf` parameter or a system property, you need to use: `--java-opts=""-conf=my-conf.json -Dkey=value""` The `--launcher-class` option determine with with _main_ class the application is launcher. It's generally {@link io.vertx.core.Launcher}, but you have use you own _main_. The redeploy feature can be used in your IDE: * Eclipse - create a _Run_ configuration, using the `io.vertx.core.Launcher` class a _main class_. In the _Program arguments_ area (in the _Arguments_ tab), write `run your-verticle-fully-qualified-name --redeploy=\\**/*.java --launcher-class=io.vertx.core.Launcher`. You can also add other parameters. The redeployment works smoothly as Eclipse incrementally compiles your files on save. * IntelliJ - create a _Run_ configuration (_Application_), set the _Main class_ to `io.vertx.core.Launcher`. In the Program arguments write: `run your-verticle-fully-qualified-name --redeploy=\\**/*.class --launcher-class=io.vertx.core.Launcher`. To trigger the redeployment, you need to _make_ the project or the module explicitly (_Build_ menu -> _Make project_). To debug your application, create your run configuration as a remote application and configure the debugger using `--java-opts`. However, don't forget to re-plug the debugger after every redeployment as a new process is created every time. You can also hook your build process in the redeploy cycle: [source] ---- java -jar target/my-fat-jar.jar --redeploy=""**/*.java"" --on-redeploy=""mvn package"" java -jar build/libs/my-fat-jar.jar --redeploy=""src/**/*.java"" --on-redeploy='./gradlew shadowJar' ---- The ""on-redeploy"" option specifies a command invoked after the shutdown of the application and before the restart. So you can hook your build tool if it updates some runtime artifacts. For instance, you can launch `gulp` or `grunt` to update your resources. Don't forget that passing parameters to your application requires the `--java-opts` param: [source] ---- java -jar target/my-fat-jar.jar --redeploy=""**/*.java"" --on-redeploy=""mvn package"" --java-opts=""-Dkey=val"" java -jar build/libs/my-fat-jar.jar --redeploy=""src/**/*.java"" --on-redeploy='./gradlew shadowJar' --java-opts=""-Dkey=val"" ---- The redeploy feature also supports the following settings: * `redeploy-scan-period` : the file system check period (in milliseconds), 250ms by default * `redeploy-grace-period` : the amount of time (in milliseconds) to wait between 2 re-deployments, 1000ms by default * `redeploy-termination-period` : the amount of time to wait after having stopped the application (before launching user command). This is useful on Windows, where the process is not killed immediately. The time is given in milliseconds. 0 ms by default. == Cluster Managers In Vert.x a cluster manager is used for various functions including: * Discovery and group membership of Vert.x nodes in a cluster * Maintaining cluster wide topic subscriber lists (so we know which nodes are interested in which event bus addresses) * Distributed Map support * Distributed Locks * Distributed Counters Cluster managers _do not_ handle the event bus inter-node transport, this is done directly by Vert.x with TCP connections. The default cluster manager used in the Vert.x distributions is one that uses http://hazelcast.com[Hazelcast] but this can be easily replaced by a different implementation as Vert.x cluster managers are pluggable. A cluster manager must implement the interface {@link io.vertx.core.spi.cluster.ClusterManager}. Vert.x locates cluster managers at run-time by using the Java https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html[Service Loader] functionality to locate instances of {@link io.vertx.core.spi.cluster.ClusterManager} on the classpath. If you are using Vert.x at the command line and you want to use clustering you should make sure the `lib` directory of the Vert.x installation contains your cluster manager jar. If you are using Vert.x from a Maven or Gradle project just add the cluster manager jar as a dependency of your project. You can also specify cluster managers programmatically if embedding Vert.x using {@link io.vertx.core.VertxOptions#setClusterManager(io.vertx.core.spi.cluster.ClusterManager)}. == Logging Vert.x logs using it's in-built logging API. The default implementation uses the JDK (JUL) logging so no extra logging dependencies are needed. === Configuring JUL logging A JUL logging configuration file can be specified in the normal JUL way by providing a system property called: `java.util.logging.config.file` with the value being your configuration file. For more information on this and the structure of a JUL config file please consult the JUL logging documentation. Vert.x also provides a slightly more convenient way to specify a configuration file without having to set a system property. Just provide a JUL config file with the name `vertx-default-jul-logging.properties` on your classpath (e.g. inside your fatjar) and Vert.x will use that to configure JUL. === Using another logging framework If you don't want Vert.x to use JUL for it's own logging you can configure it to use another logging framework, e.g. Log4J or SLF4J. To do this you should set a system property called `vertx.logger-delegate-factory-class-name` with the name of a Java class which implements the interface {@link io.vertx.core.spi.logging.LogDelegateFactory}. We provide pre-built implementations for Log4J (version 1), Log4J 2 and SLF4J with the class names `io.vertx.core.logging.Log4jLogDelegateFactory`, `io.vertx.core.logging.Log4j2LogDelegateFactory` and `io.vertx.core.logging.SLF4JLogDelegateFactory` respectively. If you want to use these implementations you should also make sure the relevant Log4J or SLF4J jars are on your classpath. Notice that, the provided delegate for Log4J 1 does not support parameterized message. The delegate for Log4J 2 uses the `{}` syntax like the SLF4J delegate. JUL delegate uses the `{x}` syntax. === Logging from your application Vert.x itself is just a library and you can use whatever logging library you prefer to log from your own application, using that logging library's API. However, if you prefer you can use the Vert.x logging facility as described above to provide logging for your application too. To do that you use {@link io.vertx.core.logging.LoggerFactory} to get an instance of {@link io.vertx.core.logging.Logger} which you then use for logging, e.g. [source,$lang] ---- {@link examples.CoreExamples#example18} ---- CAUTION: Logging backends use different formats to represent replaceable tokens in parameterized messages. As a consequence, if you rely on Vert.x parameterized logging methods, you won't be able to switch backends without changing your code. [[netty-logging]] === Netty logging When configuring logging, you should care about configuring Netty logging as well. Netty does not rely on external logging configuration (e.g system properties) and instead implements a logging configuration based on the logging libraries visible from the Netty classes: - use `SLF4J` library if it is visible - otherwise use `Log4j` if it is visible - otherwise fallback `java.util.logging` The logger implementation can be forced to a specific implementation by setting Netty's internal logger implementation directly on `io.netty.util.internal.logging.InternalLoggerFactory`: [source,java] ---- // Force logging to Log4j InternalLoggerFactory.setDefaultFactory(Log4JLoggerFactory.INSTANCE); ---- === Troubleshooting ==== SLF4J warning at startup If, when you start your application, you see the following message: ---- SLF4J: Failed to load class ""org.slf4j.impl.StaticLoggerBinder"". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. ---- It means that you have SLF4J-API in your classpath but no actual binding. Messages logged with SLF4J will be dropped. You should add a binding to your classpath. Check https://www.slf4j.org/manual.html#swapping to pick a binding and configure it. Be aware that Netty looks for the SLF4-API jar and uses it by default. ==== Connection reset by peer If your logs show a bunch of: ---- io.vertx.core.net.impl.ConnectionBase SEVERE: java.io.IOException: Connection reset by peer ---- It means that the client is resetting the HTTP connection instead of closing it. This message also indicates that you may have not consumed the complete payload (the connection was cut before you were able to). == Host name resolution Vert.x uses an an address resolver for resolving host name into IP addresses instead of the JVM built-in blocking resolver. An host name resolves to an IP address using: - the _hosts_ file of the operating system - otherwise DNS queries against a list of servers By default it will use the list of the system DNS server addresses from the environment, if that list cannot be retrieved it will use Google's public DNS servers `""8.8.8.8""` and `""8.8.4.4""`. DNS servers can be also configured when creating a {@link io.vertx.core.Vertx} instance: [source,$lang] ---- {@link examples.CoreExamples#configureDNSServers} ---- The default port of a DNS server is `53`, when a server uses a different port, this port can be set using a colon delimiter: `192.168.0.2:40000`. NOTE: sometimes it can be desirable to use the JVM built-in resolver, the JVM system property _-Dvertx.disableDnsResolver=true_ activates this behavior === Failover When a server does not reply in a timely manner, the resolver will try the next one from the list, the search is limited by {@link io.vertx.core.dns.AddressResolverOptions#setMaxQueries(int)} (the default value is `4` queries). A DNS query is considered as failed when the resolver has not received a correct answer within {@link io.vertx.core.dns.AddressResolverOptions#getQueryTimeout()} milliseconds (the default value is `5` seconds). === Server list rotation By default the dns server selection uses the first one, the remaining servers are used for failover. You can configure {@link io.vertx.core.dns.AddressResolverOptions#setRotateServers(boolean)} to `true` to let the resolver perform a round-robin selection instead. It spreads the query load among the servers and avoids all lookup to hit the first server of the list. Failover still applies and will use the next server in the list. === Hosts mapping The _hosts_ file of the operating system is used to perform an hostname lookup for an ipaddress. An alternative _hosts_ file can be used instead: [source,$lang] ---- {@link examples.CoreExamples#configureHosts} ---- === Search domains By default the resolver will use the system DNS search domains from the environment. Alternatively an explicit search domain list can be provided: [source,$lang] ---- {@link examples.CoreExamples#configureSearchDomains()} ---- When a search domain list is used, the threshold for the number of dots is {@code 1} or loaded from `/etc/resolv.conf` on Linux, it can be configured to a specific value with {@link io.vertx.core.dns.AddressResolverOptions#setNdots(int)}. == High Availability and Fail-Over Vert.x allows you to run your verticles with high availability (HA) support. In that case, when a vert.x instance running a verticle dies abruptly, the verticle is migrated to another vertx instance. The vert.x instances must be in the same cluster. === Automatic failover When vert.x runs with _HA_ enabled, if a vert.x instance where a verticle runs fails or dies, the verticle is redeployed automatically on another vert.x instance of the cluster. We call this _verticle fail-over_. To run vert.x with the _HA_ enabled, just add the `-ha` flag to the command line: [source] ---- vertx run my-verticle.js -ha ---- Now for HA to work, you need more than one Vert.x instances in the cluster, so let's say you have another Vert.x instance that you have already started, for example: [source] ---- vertx run my-other-verticle.js -ha ---- If the Vert.x instance that is running `my-verticle.js` now dies (you can test this by killing the process with `kill -9`), the Vert.x instance that is running `my-other-verticle.js` will automatic deploy `my-verticle .js` so now that Vert.x instance is running both verticles. NOTE: the migration is only possible if the second vert.x instance has access to the verticle file (here `my-verticle.js`). IMPORTANT: Please note that cleanly closing a Vert.x instance will not cause failover to occur, e.g. `CTRL-C` or `kill -SIGINT` You can also start _bare_ Vert.x instances - i.e. instances that are not initially running any verticles, they will also failover for nodes in the cluster. To start a bare instance you simply do: [source] ---- vertx run -ha ---- When using the `-ha` switch you do not need to provide the `-cluster` switch, as a cluster is assumed if you want HA. NOTE: depending on your cluster configuration, you may need to customize the cluster manager configuration (Hazelcast by default), and/or add the `cluster-host` and `cluster-port` parameters. === HA groups When running a Vert.x instance with HA you can also optional specify a _HA group_. A HA group denotes a logical group of nodes in the cluster. Only nodes with the same HA group will failover onto one another. If you don't specify a HA group the default group `+++__DEFAULT__+++` is used. To specify an HA group you use the `-hagroup` switch when running the verticle, e.g. [source] ---- vertx run my-verticle.js -ha -hagroup my-group ---- Let's look at an example: In a first terminal: [source] ---- vertx run my-verticle.js -ha -hagroup g1 ---- In a second terminal, let's run another verticle using the same group: [source] ---- vertx run my-other-verticle.js -ha -hagroup g1 ---- Finally, in a third terminal, launch another verticle using a different group: [source] ---- vertx run yet-another-verticle.js -ha -hagroup g2 ---- If we kill the instance in terminal 1, it will fail over to the instance in terminal 2, not the instance in terminal 3 as that has a different group. If we kill the instance in terminal 3, it won't get failed over as there is no other vert.x instance in that group. === Dealing with network partitions - Quora The HA implementation also supports quora. A quorum is the minimum number of votes that a distributed transaction has to obtain in order to be allowed to perform an operation in a distributed system. When starting a Vert.x instance you can instruct it that it requires a `quorum` before any HA deployments will be deployed. In this context, a quorum is a minimum number of nodes for a particular group in the cluster. Typically you chose your quorum size to `Q = 1 + N/2` where `N` is the number of nodes in the group. If there are less than `Q` nodes in the cluster the HA deployments will undeploy. They will redeploy again if/when a quorum is re-attained. By doing this you can prevent against network partitions, a.k.a. _split brain_. There is more information on quora http://en.wikipedia.org/wiki/Quorum_(distributed_computing)[here]. To run vert.x instances with a quorum you specify `-quorum` on the command line, e.g. In a first terminal: [source] ---- vertx run my-verticle.js -ha -quorum 3 ---- At this point the Vert.x instance will start but not deploy the module (yet) because there is only one node in the cluster, not 3. In a second terminal: [source] ---- vertx run my-other-verticle.js -ha -quorum 3 ---- At this point the Vert.x instance will start but not deploy the module (yet) because there are only two nodes in the cluster, not 3. In a third console, you can start another instance of vert.x: [source] ---- vertx run yet-another-verticle.js -ha -quorum 3 ---- Yay! - we have three nodes, that's a quorum. At this point the modules will automatically deploy on all instances. If we now close or kill one of the nodes the modules will automatically undeploy on the other nodes, as there is no longer a quorum. Quora can also be used in conjunction with ha groups. In that case, quora are resolved for each particular group. == Native transports Vert.x can run with http://netty.io/wiki/native-transports.html[native transports] (when available) on BSD (OSX) and Linux: [source,$lang] ---- {@link examples.CoreExamples#configureNative()} ---- NOTE: preferring native transport will not prevent the application to execute, if your application requires native transport, you need to check {@link io.vertx.core.Vertx#isNativeTransportEnabled()}. === Native Linux Transport You need to add the following dependency in your classpath: [source,xml] ---- io.netty netty-transport-native-epoll 4.1.15.Final linux-x86_64 ---- Native on Linux gives you extra networking options: * SO_REUSEPORT * TCP_QUICKACK * TCP_CORK * TCP_FASTOPEN [source,$lang] ---- {@link examples.CoreExamples#configureLinuxOptions} ---- === Native BSD Transport You need to add the following dependency in your classpath: [source,xml] ---- io.netty netty-transport-native-epoll 4.1.15.Final osx-x86_64 ---- MacOS Sierra and above are supported. Native on BSD gives you extra networking options: * SO_REUSEPORT [source,$lang] ---- {@link examples.CoreExamples#configureBSDOptions} ---- === Domain sockets Natives provide domain sockets support for `NetServer` and `HttpServer`: [source,$lang] ---- {@link examples.CoreExamples#serverWithDomainSockets} ---- Or for http: [source,$lang] ---- {@link examples.CoreExamples#httpServerWithDomainSockets} ---- As well as `NetClient`: [source,$lang] ---- {@link examples.CoreExamples#clientWithDomainSockets} ---- NOTE: support for `HttpClient` can be expected in later versions of Vert.x == Security notes Vert.x is a toolkit, not an opinionated framework where we force you to do things in a certain way. This gives you great power as a developer but with that comes great responsibility. As with any toolkit, it's possible to write insecure applications, so you should always be careful when developing your application especially if it's exposed to the public (e.g. over the internet). === Web applications If writing a web application it's highly recommended that you use Vert.x-Web instead of Vert.x core directly for serving resources and handling file uploads. Vert.x-Web normalises the path in requests to prevent malicious clients from crafting URLs to access resources outside of the web root. Similarly for file uploads Vert.x-Web provides functionality for uploading to a known place on disk and does not rely on the filename provided by the client in the upload which could be crafted to upload to a different place on disk. Vert.x core itself does not provide such checks so it would be up to you as a developer to implement them yourself. === Clustered event bus traffic When clustering the event bus between different Vert.x nodes on a network, the traffic is sent un-encrypted across the wire, so do not use this if you have confidential data to send and your Vert.x nodes are not on a trusted network. === Standard security best practices Any service can have potentially vulnerabilities whether it's written using Vert.x or any other toolkit so always follow security best practice, especially if your service is public facing. For example you should always run them in a DMZ and with an user account that has limited rights in order to limit the extent of damage in case the service was compromised. == Vert.x Command Line Interface API include::cli.adoc[] == The vert.x Launcher The vert.x {@link io.vertx.core.Launcher} is used in _fat jar_ as main class, and by the `vertx` command line utility. It executes a set of _commands_ such as _run_, _bare_, _start_... === Extending the vert.x Launcher You can extend the set of command by implementing your own {@link io.vertx.core.spi.launcher.Command} (in Java only): [source, java] ---- @Name(""my-command"") @Summary(""A simple hello command."") public class MyCommand extends DefaultCommand { private String name; @Option(longName = ""name"", required = true) public void setName(String n) { this.name = n; } @Override public void run() throws CLIException { System.out.println(""Hello "" + name); } } ---- You also need an implementation of {@link io.vertx.core.spi.launcher.CommandFactory}: [source, java] ---- public class HelloCommandFactory extends DefaultCommandFactory { public HelloCommandFactory() { super(HelloCommand.class); } } ---- Then, create the `src/main/resources/META-INF/services/io.vertx.core.spi.launcher.CommandFactory` and add a line indicating the fully qualified name of the factory: ---- io.vertx.core.launcher.example.HelloCommandFactory ---- Builds the jar containing the command. Be sure to includes the SPI file (`META-INF/services/io.vertx.core.spi.launcher.CommandFactory`). Then, place the jar containing the command into the classpath of your fat-jar (or include it inside) or in the `lib` directory of your vert.x distribution, and you would be able to execute: [source] ---- vertx hello vert.x java -jar my-fat-jar.jar hello vert.x ---- === Using the Launcher in fat jars To use the {@link io.vertx.core.Launcher} class in a _fat-jar_ just set the `Main-Class` of the _MANIFEST_ to `io.vertx.core.Launcher`. In addition, set the `Main-Verticle` _MANIFEST_ entry to the name of your main verticle. By default, it executed the `run` command. However, you can configure the default command by setting the `Main-Command` _MANIFEST_ entry. The default command is used if the _fat jar_ is launched without a command. === Sub-classing the Launcher You can also create a sub-class of {@link io.vertx.core.Launcher} to start your application. The class has been designed to be easily extensible. A {@link io.vertx.core.Launcher} sub-class can: * customize the vert.x configuration in {@link io.vertx.core.Launcher#beforeStartingVertx(io.vertx.core.VertxOptions)} * retrieve the vert.x instance created by the ""run"" or ""bare"" command by overriding {@link io.vertx.core.Launcher#afterStartingVertx(io.vertx.core.Vertx)} * configure the default verticle and command with {@link io.vertx.core.impl.launcher.VertxCommandLauncher#getMainVerticle()} and {@link io.vertx.core.impl.launcher.VertxCommandLauncher#getDefaultCommand()} * add / remove commands using {@link io.vertx.core.impl.launcher.VertxCommandLauncher#register(java.lang.Class)} and {@link io.vertx.core.impl.launcher.VertxCommandLauncher#unregister(java.lang.String)} === Launcher and exit code When you use the {@link io.vertx.core.Launcher} class as main class, it uses the following exit code: * {@code 0} if the process ends smoothly, or if an uncaught error is thrown * {@code 1} for general purpose error * {@code 11} if Vert.x cannot be initialized * {@code 12} if a spawn process cannot be started, found or stopped. This error code is used by the `start` and `stop` command * {@code 14} if the system configuration is not meeting the system requirement (shc as java not found) * {@code 15} if the main verticle cannot be deployed == Configuring Vert.x cache When Vert.x needs to read a file from the classpath (embedded in a fat jar, in a jar form the classpath or a file that is on the classpath), it copies it to a cache directory. The reason behind this is simple: reading a file from a jar or from an input stream is blocking. So to avoid to pay the price every time, Vert.x copies the file to its cache directory and reads it from there every subsequent read. This behavior can be configured. First, by default, Vert.x uses `$CWD/.vertx` as cache directory. It creates a unique directory inside this one to avoid conflicts. This location can be configured by using the `vertx.cacheDirBase` system property. For instance if the current working directory is not writable (such as in an immutable container context), launch your application with: [source] ---- vertx run my.Verticle -Dvertx.cacheDirBase=/tmp/vertx-cache # or java -jar my-fat.jar vertx.cacheDirBase=/tmp/vertx-cache ---- IMPORTANT: the directory must be **writable**. When you are editing resources such as HTML, CSS or JavaScript, this cache mechanism can be annoying as it serves only the first version of the file (and so you won't see your edits if you reload your page). To avoid this behavior, launch your application with `-Dvertx.disableFileCaching=true`. With this setting, Vert.x still uses the cache, but always refresh the version stored in the cache with the original source. So if you edit a file served from the classpath and refresh your browser, Vert.x reads it from the classpath, copies it to the cache directory and serves it from there. Do not use this setting in production, it can kill your performances. Finally, you can disable completely the cache by using `-Dvertx.disableFileCPResolving=true`. This setting is not without consequences. Vert.x would be unable to read any files from the classpath (only from the file system). Be very careful when using this settings. ",16300,True,2618.1806024339858,median "[[kafka-component]] == Kafka Component *Available as of Camel version 2.13* The *kafka:* component is used for communicating with http://kafka.apache.org/[Apache Kafka] message broker. Maven users will need to add the following dependency to their `pom.xml` for this component. [source,xml] ------------------------------------------------------------ org.apache.camel camel-kafka x.x.x ------------------------------------------------------------ === URI format [source,java] --------------------------- kafka:topic[?options] --------------------------- === Options // component options: START The Kafka component supports 8 options, which are listed below. [width=""100%"",cols=""2,5,^1,2"",options=""header""] |=== | Name | Description | Default | Type | *configuration* (common) | Allows to pre-configure the Kafka component with common options that the endpoints will reuse. | | KafkaConfiguration | *brokers* (common) | URL of the Kafka brokers to use. The format is host1:port1,host2:port2, and the list can be a subset of brokers or a VIP pointing to a subset of brokers. This option is known as bootstrap.servers in the Kafka documentation. | | String | *workerPool* (advanced) | To use a shared custom worker pool for continue routing Exchange after kafka server has acknowledge the message that was sent to it from KafkaProducer using asynchronous non-blocking processing. If using this option then you must handle the lifecycle of the thread pool to shut the pool down when no longer needed. | | ExecutorService | *useGlobalSslContext Parameters* (security) | Enable usage of global SSL context parameters. | false | boolean | *breakOnFirstError* (consumer) | This options controls what happens when a consumer is processing an exchange and it fails. If the option is false then the consumer continues to the next message and processes it. If the option is true then the consumer breaks out, and will seek back to offset of the message that caused a failure, and then re-attempt to process this message. However this can lead to endless processing of the same message if its bound to fail every time, eg a poison message. Therefore its recommended to deal with that for example by using Camel's error handler. | false | boolean | *allowManualCommit* (consumer) | Whether to allow doing manual commits via KafkaManualCommit. If this option is enabled then an instance of KafkaManualCommit is stored on the Exchange message header, which allows end users to access this API and perform manual offset commits via the Kafka consumer. | false | boolean | *kafkaManualCommit Factory* (consumer) | Factory to use for creating KafkaManualCommit instances. This allows to plugin a custom factory to create custom KafkaManualCommit instances in case special logic is needed when doing manual commits that deviates from the default implementation that comes out of the box. | | KafkaManualCommit Factory | *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean |=== // component options: END // endpoint options: START The Kafka endpoint is configured using URI syntax: ---- kafka:topic ---- with the following path and query parameters: ==== Path Parameters (1 parameters): [width=""100%"",cols=""2,5,^1,2"",options=""header""] |=== | Name | Description | Default | Type | *topic* | *Required* Name of the topic to use. On the consumer you can use comma to separate multiple topics. A producer can only send a message to a single topic. | | String |=== ==== Query Parameters (95 parameters): [width=""100%"",cols=""2,5,^1,2"",options=""header""] |=== | Name | Description | Default | Type | *brokers* (common) | URL of the Kafka brokers to use. The format is host1:port1,host2:port2, and the list can be a subset of brokers or a VIP pointing to a subset of brokers. This option is known as bootstrap.servers in the Kafka documentation. | | String | *clientId* (common) | The client id is a user-specified string sent in each request to help trace calls. It should logically identify the application making the request. | | String | *headerFilterStrategy* (common) | To use a custom HeaderFilterStrategy to filter header to and from Camel message. | | HeaderFilterStrategy | *reconnectBackoffMaxMs* (common) | The maximum amount of time in milliseconds to wait when reconnecting to a broker that has repeatedly failed to connect. If provided, the backoff per host will increase exponentially for each consecutive connection failure, up to this maximum. After calculating the backoff increase, 20% random jitter is added to avoid connection storms. | 1000 | Integer | *allowManualCommit* (consumer) | Whether to allow doing manual commits via KafkaManualCommit. If this option is enabled then an instance of KafkaManualCommit is stored on the Exchange message header, which allows end users to access this API and perform manual offset commits via the Kafka consumer. | false | boolean | *autoCommitEnable* (consumer) | If true, periodically commit to ZooKeeper the offset of messages already fetched by the consumer. This committed offset will be used when the process fails as the position from which the new consumer will begin. | true | Boolean | *autoCommitIntervalMs* (consumer) | The frequency in ms that the consumer offsets are committed to zookeeper. | 5000 | Integer | *autoCommitOnStop* (consumer) | Whether to perform an explicit auto commit when the consumer stops to ensure the broker has a commit from the last consumed message. This requires the option autoCommitEnable is turned on. The possible values are: sync, async, or none. And sync is the default value. | sync | String | *autoOffsetReset* (consumer) | What to do when there is no initial offset in ZooKeeper or if an offset is out of range: earliest : automatically reset the offset to the earliest offset latest : automatically reset the offset to the latest offset fail: throw exception to the consumer | latest | String | *breakOnFirstError* (consumer) | This options controls what happens when a consumer is processing an exchange and it fails. If the option is false then the consumer continues to the next message and processes it. If the option is true then the consumer breaks out, and will seek back to offset of the message that caused a failure, and then re-attempt to process this message. However this can lead to endless processing of the same message if its bound to fail every time, eg a poison message. Therefore its recommended to deal with that for example by using Camel's error handler. | false | boolean | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | *checkCrcs* (consumer) | Automatically check the CRC32 of the records consumed. This ensures no on-the-wire or on-disk corruption to the messages occurred. This check adds some overhead, so it may be disabled in cases seeking extreme performance. | true | Boolean | *consumerRequestTimeoutMs* (consumer) | The configuration controls the maximum amount of time the client will wait for the response of a request. If the response is not received before the timeout elapses the client will resend the request if necessary or fail the request if retries are exhausted. | 40000 | Integer | *consumersCount* (consumer) | The number of consumers that connect to kafka server | 1 | int | *consumerStreams* (consumer) | Number of concurrent consumers on the consumer | 10 | int | *fetchMaxBytes* (consumer) | The maximum amount of data the server should return for a fetch request This is not an absolute maximum, if the first message in the first non-empty partition of the fetch is larger than this value, the message will still be returned to ensure that the consumer can make progress. The maximum message size accepted by the broker is defined via message.max.bytes (broker config) or max.message.bytes (topic config). Note that the consumer performs multiple fetches in parallel. | 52428800 | Integer | *fetchMinBytes* (consumer) | The minimum amount of data the server should return for a fetch request. If insufficient data is available the request will wait for that much data to accumulate before answering the request. | 1 | Integer | *fetchWaitMaxMs* (consumer) | The maximum amount of time the server will block before answering the fetch request if there isn't sufficient data to immediately satisfy fetch.min.bytes | 500 | Integer | *groupId* (consumer) | A string that uniquely identifies the group of consumer processes to which this consumer belongs. By setting the same group id multiple processes indicate that they are all part of the same consumer group. This option is required for consumers. | | String | *heartbeatIntervalMs* (consumer) | The expected time between heartbeats to the consumer coordinator when using Kafka's group management facilities. Heartbeats are used to ensure that the consumer's session stays active and to facilitate rebalancing when new consumers join or leave the group. The value must be set lower than session.timeout.ms, but typically should be set no higher than 1/3 of that value. It can be adjusted even lower to control the expected time for normal rebalances. | 3000 | Integer | *kafkaHeaderDeserializer* (consumer) | Sets custom KafkaHeaderDeserializer for deserialization kafka headers values to camel headers values. | | KafkaHeaderDeserializer | *keyDeserializer* (consumer) | Deserializer class for key that implements the Deserializer interface. | org.apache.kafka.common.serialization.StringDeserializer | String | *maxPartitionFetchBytes* (consumer) | The maximum amount of data per-partition the server will return. The maximum total memory used for a request will be #partitions max.partition.fetch.bytes. This size must be at least as large as the maximum message size the server allows or else it is possible for the producer to send messages larger than the consumer can fetch. If that happens, the consumer can get stuck trying to fetch a large message on a certain partition. | 1048576 | Integer | *maxPollIntervalMs* (consumer) | The maximum delay between invocations of poll() when using consumer group management. This places an upper bound on the amount of time that the consumer can be idle before fetching more records. If poll() is not called before expiration of this timeout, then the consumer is considered failed and the group will rebalance in order to reassign the partitions to another member. | | Long | *maxPollRecords* (consumer) | The maximum number of records returned in a single call to poll() | 500 | Integer | *offsetRepository* (consumer) | The offset repository to use in order to locally store the offset of each partition of the topic. Defining one will disable the autocommit. | | StateRepository | *partitionAssignor* (consumer) | The class name of the partition assignment strategy that the client will use to distribute partition ownership amongst consumer instances when group management is used | org.apache.kafka.clients.consumer.RangeAssignor | String | *pollTimeoutMs* (consumer) | The timeout used when polling the KafkaConsumer. | 5000 | Long | *seekTo* (consumer) | Set if KafkaConsumer will read from beginning or end on startup: beginning : read from beginning end : read from end This is replacing the earlier property seekToBeginning | | String | *sessionTimeoutMs* (consumer) | The timeout used to detect failures when using Kafka's group management facilities. | 10000 | Integer | *specificAvroReader* (consumer) | This enables the use of a specific Avro reader for use with the Confluent schema registry and the io.confluent.kafka.serializers.KafkaAvroDeserializer. This option is only available in the Confluent Kafka product (not standard Apache Kafka) | false | boolean | *topicIsPattern* (consumer) | Whether the topic is a pattern (regular expression). This can be used to subscribe to dynamic number of topics matching the pattern. | false | boolean | *valueDeserializer* (consumer) | Deserializer class for value that implements the Deserializer interface. | org.apache.kafka.common.serialization.StringDeserializer | String | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern | *bridgeEndpoint* (producer) | If the option is true, then KafkaProducer will ignore the KafkaConstants.TOPIC header setting of the inbound message. | false | boolean | *bufferMemorySize* (producer) | The total bytes of memory the producer can use to buffer records waiting to be sent to the server. If records are sent faster than they can be delivered to the server the producer will either block or throw an exception based on the preference specified by block.on.buffer.full.This setting should correspond roughly to the total memory the producer will use, but is not a hard bound since not all memory the producer uses is used for buffering. Some additional memory will be used for compression (if compression is enabled) as well as for maintaining in-flight requests. | 33554432 | Integer | *circularTopicDetection* (producer) | If the option is true, then KafkaProducer will detect if the message is attempted to be sent back to the same topic it may come from, if the message was original from a kafka consumer. If the KafkaConstants.TOPIC header is the same as the original kafka consumer topic, then the header setting is ignored, and the topic of the producer endpoint is used. In other words this avoids sending the same message back to where it came from. This option is not in use if the option bridgeEndpoint is set to true. | true | boolean | *compressionCodec* (producer) | This parameter allows you to specify the compression codec for all data generated by this producer. Valid values are none, gzip and snappy. | none | String | *connectionMaxIdleMs* (producer) | Close idle connections after the number of milliseconds specified by this config. | 540000 | Integer | *enableIdempotence* (producer) | If set to 'true' the producer will ensure that exactly one copy of each message is written in the stream. If 'false', producer retries may write duplicates of the retried message in the stream. If set to true this option will require max.in.flight.requests.per.connection to be set to 1 and retries cannot be zero and additionally acks must be set to 'all'. | false | boolean | *kafkaHeaderSerializer* (producer) | Sets custom KafkaHeaderDeserializer for serialization camel headers values to kafka headers values. | | KafkaHeaderSerializer | *key* (producer) | The record key (or null if no key is specified). If this option has been configured then it take precedence over header KafkaConstants#KEY | | String | *keySerializerClass* (producer) | The serializer class for keys (defaults to the same as for messages if nothing is given). | org.apache.kafka.common.serialization.StringSerializer | String | *lingerMs* (producer) | The producer groups together any records that arrive in between request transmissions into a single batched request. Normally this occurs only under load when records arrive faster than they can be sent out. However in some circumstances the client may want to reduce the number of requests even under moderate load. This setting accomplishes this by adding a small amount of artificial delaythat is, rather than immediately sending out a record the producer will wait for up to the given delay to allow other records to be sent so that the sends can be batched together. This can be thought of as analogous to Nagle's algorithm in TCP. This setting gives the upper bound on the delay for batching: once we get batch.size worth of records for a partition it will be sent immediately regardless of this setting, however if we have fewer than this many bytes accumulated for this partition we will 'linger' for the specified time waiting for more records to show up. This setting defaults to 0 (i.e. no delay). Setting linger.ms=5, for example, would have the effect of reducing the number of requests sent but would add up to 5ms of latency to records sent in the absense of load. | 0 | Integer | *maxBlockMs* (producer) | The configuration controls how long sending to kafka will block. These methods can be blocked for multiple reasons. For e.g: buffer full, metadata unavailable.This configuration imposes maximum limit on the total time spent in fetching metadata, serialization of key and value, partitioning and allocation of buffer memory when doing a send(). In case of partitionsFor(), this configuration imposes a maximum time threshold on waiting for metadata | 60000 | Integer | *maxInFlightRequest* (producer) | The maximum number of unacknowledged requests the client will send on a single connection before blocking. Note that if this setting is set to be greater than 1 and there are failed sends, there is a risk of message re-ordering due to retries (i.e., if retries are enabled). | 5 | Integer | *maxRequestSize* (producer) | The maximum size of a request. This is also effectively a cap on the maximum record size. Note that the server has its own cap on record size which may be different from this. This setting will limit the number of record batches the producer will send in a single request to avoid sending huge requests. | 1048576 | Integer | *metadataMaxAgeMs* (producer) | The period of time in milliseconds after which we force a refresh of metadata even if we haven't seen any partition leadership changes to proactively discover any new brokers or partitions. | 300000 | Integer | *metricReporters* (producer) | A list of classes to use as metrics reporters. Implementing the MetricReporter interface allows plugging in classes that will be notified of new metric creation. The JmxReporter is always included to register JMX statistics. | | String | *metricsSampleWindowMs* (producer) | The number of samples maintained to compute metrics. | 30000 | Integer | *noOfMetricsSample* (producer) | The number of samples maintained to compute metrics. | 2 | Integer | *partitioner* (producer) | The partitioner class for partitioning messages amongst sub-topics. The default partitioner is based on the hash of the key. | org.apache.kafka.clients.producer.internals.DefaultPartitioner | String | *partitionKey* (producer) | The partition to which the record will be sent (or null if no partition was specified). If this option has been configured then it take precedence over header KafkaConstants#PARTITION_KEY | | Integer | *producerBatchSize* (producer) | The producer will attempt to batch records together into fewer requests whenever multiple records are being sent to the same partition. This helps performance on both the client and the server. This configuration controls the default batch size in bytes. No attempt will be made to batch records larger than this size.Requests sent to brokers will contain multiple batches, one for each partition with data available to be sent.A small batch size will make batching less common and may reduce throughput (a batch size of zero will disable batching entirely). A very large batch size may use memory a bit more wastefully as we will always allocate a buffer of the specified batch size in anticipation of additional records. | 16384 | Integer | *queueBufferingMaxMessages* (producer) | The maximum number of unsent messages that can be queued up the producer when using async mode before either the producer must be blocked or data must be dropped. | 10000 | Integer | *receiveBufferBytes* (producer) | The size of the TCP receive buffer (SO_RCVBUF) to use when reading data. | 65536 | Integer | *reconnectBackoffMs* (producer) | The amount of time to wait before attempting to reconnect to a given host. This avoids repeatedly connecting to a host in a tight loop. This backoff applies to all requests sent by the consumer to the broker. | 50 | Integer | *recordMetadata* (producer) | Whether the producer should store the RecordMetadata results from sending to Kafka. The results are stored in a List containing the RecordMetadata metadata's. The list is stored on a header with the key KafkaConstants#KAFKA_RECORDMETA | true | boolean | *requestRequiredAcks* (producer) | The number of acknowledgments the producer requires the leader to have received before considering a request complete. This controls the durability of records that are sent. The following settings are common: acks=0 If set to zero then the producer will not wait for any acknowledgment from the server at all. The record will be immediately added to the socket buffer and considered sent. No guarantee can be made that the server has received the record in this case, and the retries configuration will not take effect (as the client won't generally know of any failures). The offset given back for each record will always be set to -1. acks=1 This will mean the leader will write the record to its local log but will respond without awaiting full acknowledgement from all followers. In this case should the leader fail immediately after acknowledging the record but before the followers have replicated it then the record will be lost. acks=all This means the leader will wait for the full set of in-sync replicas to acknowledge the record. This guarantees that the record will not be lost as long as at least one in-sync replica remains alive. This is the strongest available guarantee. | 1 | String | *requestTimeoutMs* (producer) | The amount of time the broker will wait trying to meet the request.required.acks requirement before sending back an error to the client. | 305000 | Integer | *retries* (producer) | Setting a value greater than zero will cause the client to resend any record whose send fails with a potentially transient error. Note that this retry is no different than if the client resent the record upon receiving the error. Allowing retries will potentially change the ordering of records because if two records are sent to a single partition, and the first fails and is retried but the second succeeds, then the second record may appear first. | 0 | Integer | *retryBackoffMs* (producer) | Before each retry, the producer refreshes the metadata of relevant topics to see if a new leader has been elected. Since leader election takes a bit of time, this property specifies the amount of time that the producer waits before refreshing the metadata. | 100 | Integer | *sendBufferBytes* (producer) | Socket write buffer size | 131072 | Integer | *serializerClass* (producer) | The serializer class for messages. | org.apache.kafka.common.serialization.StringSerializer | String | *workerPool* (producer) | To use a custom worker pool for continue routing Exchange after kafka server has acknowledge the message that was sent to it from KafkaProducer using asynchronous non-blocking processing. | | ExecutorService | *workerPoolCoreSize* (producer) | Number of core threads for the worker pool for continue routing Exchange after kafka server has acknowledge the message that was sent to it from KafkaProducer using asynchronous non-blocking processing. | 10 | Integer | *workerPoolMaxSize* (producer) | Maximum number of threads for the worker pool for continue routing Exchange after kafka server has acknowledge the message that was sent to it from KafkaProducer using asynchronous non-blocking processing. | 20 | Integer | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean | *interceptorClasses* (monitoring) | Sets interceptors for producer or consumers. Producer interceptors have to be classes implementing org.apache.kafka.clients.producer.ProducerInterceptor Consumer interceptors have to be classes implementing org.apache.kafka.clients.consumer.ConsumerInterceptor Note that if you use Producer interceptor on a consumer it will throw a class cast exception in runtime | | String | *kerberosBeforeReloginMin Time* (security) | Login thread sleep time between refresh attempts. | 60000 | Integer | *kerberosInitCmd* (security) | Kerberos kinit command path. Default is /usr/bin/kinit | /usr/bin/kinit | String | *kerberosPrincipalToLocal Rules* (security) | A list of rules for mapping from principal names to short names (typically operating system usernames). The rules are evaluated in order and the first rule that matches a principal name is used to map it to a short name. Any later rules in the list are ignored. By default, principal names of the form {username}/{hostname}{REALM} are mapped to {username}. For more details on the format please see the security authorization and acls documentation.. Multiple values can be separated by comma | DEFAULT | String | *kerberosRenewJitter* (security) | Percentage of random jitter added to the renewal time. | 0.05 | Double | *kerberosRenewWindowFactor* (security) | Login thread will sleep until the specified window factor of time from last refresh to ticket's expiry has been reached, at which time it will try to renew the ticket. | 0.8 | Double | *saslJaasConfig* (security) | Expose the kafka sasl.jaas.config parameter Example: org.apache.kafka.common.security.plain.PlainLoginModule required username=USERNAME password=PASSWORD; | | String | *saslKerberosServiceName* (security) | The Kerberos principal name that Kafka runs as. This can be defined either in Kafka's JAAS config or in Kafka's config. | | String | *saslMechanism* (security) | The Simple Authentication and Security Layer (SASL) Mechanism used. For the valid values see a href= http://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtmlhttp://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml | GSSAPI | String | *securityProtocol* (security) | Protocol used to communicate with brokers. SASL_PLAINTEXT, PLAINTEXT and SSL are supported | PLAINTEXT | String | *sslCipherSuites* (security) | A list of cipher suites. This is a named combination of authentication, encryption, MAC and key exchange algorithm used to negotiate the security settings for a network connection using TLS or SSL network protocol.By default all the available cipher suites are supported. | | String | *sslContextParameters* (security) | SSL configuration using a Camel SSLContextParameters object. If configured it's applied before the other SSL endpoint parameters. | | SSLContextParameters | *sslEnabledProtocols* (security) | The list of protocols enabled for SSL connections. TLSv1.2, TLSv1.1 and TLSv1 are enabled by default. | TLSv1.2,TLSv1.1,TLSv1 | String | *sslEndpointAlgorithm* (security) | The endpoint identification algorithm to validate server hostname using server certificate. | | String | *sslKeymanagerAlgorithm* (security) | The algorithm used by key manager factory for SSL connections. Default value is the key manager factory algorithm configured for the Java Virtual Machine. | SunX509 | String | *sslKeyPassword* (security) | The password of the private key in the key store file. This is optional for client. | | String | *sslKeystoreLocation* (security) | The location of the key store file. This is optional for client and can be used for two-way authentication for client. | | String | *sslKeystorePassword* (security) | The store password for the key store file.This is optional for client and only needed if ssl.keystore.location is configured. | | String | *sslKeystoreType* (security) | The file format of the key store file. This is optional for client. Default value is JKS | JKS | String | *sslProtocol* (security) | The SSL protocol used to generate the SSLContext. Default setting is TLS, which is fine for most cases. Allowed values in recent JVMs are TLS, TLSv1.1 and TLSv1.2. SSL, SSLv2 and SSLv3 may be supported in older JVMs, but their usage is discouraged due to known security vulnerabilities. | TLS | String | *sslProvider* (security) | The name of the security provider used for SSL connections. Default value is the default security provider of the JVM. | | String | *sslTrustmanagerAlgorithm* (security) | The algorithm used by trust manager factory for SSL connections. Default value is the trust manager factory algorithm configured for the Java Virtual Machine. | PKIX | String | *sslTruststoreLocation* (security) | The location of the trust store file. | | String | *sslTruststoreType* (security) | The file format of the trust store file. Default value is JKS. | JKS | String | *schemaRegistryURL* (confluent) | URL of the Confluent schema registry servers to use. The format is host1:port1,host2:port2. This is known as schema.registry.url in the Confluent documentation. This option is only available in the Confluent Kafka product (not standard Apache Kafka) | | String | *sslTruststorePassword* (security) | The password for the trust store file. | | String | *specificAvroReader* (confluent, consumer) | This enables the use of a specific Avro reader for use with the Confluent schema registry and the io.confluent.kafka.serializers.KafkaAvroDeserializer. The default value is false. | false | boolean |=== // endpoint options: END // spring-boot-auto-configure options: START === Spring Boot Auto-Configuration When using Spring Boot make sure to use the following Maven dependency to have support for auto configuration: [source,xml] ---- org.apache.camel camel-kafka-starter x.x.x ---- The component supports 99 options, which are listed below. [width=""100%"",cols=""2,5,^1,2"",options=""header""] |=== | Name | Description | Default | Type | *camel.component.kafka.allow-manual-commit* | Whether to allow doing manual commits via KafkaManualCommit. If this option is enabled then an instance of KafkaManualCommit is stored on the Exchange message header, which allows end users to access this API and perform manual offset commits via the Kafka consumer. | false | Boolean | *camel.component.kafka.break-on-first-error* | This options controls what happens when a consumer is processing an exchange and it fails. If the option is false then the consumer continues to the next message and processes it. If the option is true then the consumer breaks out, and will seek back to offset of the message that caused a failure, and then re-attempt to process this message. However this can lead to endless processing of the same message if its bound to fail every time, eg a poison message. Therefore its recommended to deal with that for example by using Camel's error handler. | false | Boolean | *camel.component.kafka.brokers* | URL of the Kafka brokers to use. The format is host1:port1,host2:port2, and the list can be a subset of brokers or a VIP pointing to a subset of brokers. This option is known as bootstrap.servers in the Kafka documentation. | | String | *camel.component.kafka.configuration.allow-manual-commit* | Whether to allow doing manual commits via {@link KafkaManualCommit}.

If this option is enabled then an instance of {@link KafkaManualCommit} is stored on the {@link Exchange} message header, which allows end users to access this API and perform manual offset commits via the Kafka consumer. | false | Boolean | *camel.component.kafka.configuration.auto-commit-enable* | If true, periodically commit to ZooKeeper the offset of messages already fetched by the consumer. This committed offset will be used when the process fails as the position from which the new consumer will begin. | true | Boolean | *camel.component.kafka.configuration.auto-commit-interval-ms* | The frequency in ms that the consumer offsets are committed to zookeeper. | 5000 | Integer | *camel.component.kafka.configuration.auto-commit-on-stop* | Whether to perform an explicit auto commit when the consumer stops to ensure the broker has a commit from the last consumed message. This requires the option autoCommitEnable is turned on. The possible values are: sync, async, or none. And sync is the default value. | sync | String | *camel.component.kafka.configuration.auto-offset-reset* | What to do when there is no initial offset in ZooKeeper or if an offset is out of range: earliest : automatically reset the offset to the earliest offset latest : automatically reset the offset to the latest offset fail: throw exception to the consumer | latest | String | *camel.component.kafka.configuration.break-on-first-error* | This options controls what happens when a consumer is processing an exchange and it fails. If the option is false then the consumer continues to the next message and processes it. If the option is true then the consumer breaks out, and will seek back to offset of the message that caused a failure, and then re-attempt to process this message. However this can lead to endless processing of the same message if its bound to fail every time, eg a poison message. Therefore its recommended to deal with that for example by using Camel's error handler. | false | Boolean | *camel.component.kafka.configuration.bridge-endpoint* | If the option is true, then KafkaProducer will ignore the KafkaConstants.TOPIC header setting of the inbound message. | false | Boolean | *camel.component.kafka.configuration.brokers* | URL of the Kafka brokers to use. The format is host1:port1,host2:port2, and the list can be a subset of brokers or a VIP pointing to a subset of brokers.

This option is known as bootstrap.servers in the Kafka documentation. | | String | *camel.component.kafka.configuration.buffer-memory-size* | The total bytes of memory the producer can use to buffer records waiting to be sent to the server. If records are sent faster than they can be delivered to the server the producer will either block or throw an exception based on the preference specified by block.on.buffer.full.This setting should correspond roughly to the total memory the producer will use, but is not a hard bound since not all memory the producer uses is used for buffering. Some additional memory will be used for compression (if compression is enabled) as well as for maintaining in-flight requests. | 33554432 | Integer | *camel.component.kafka.configuration.check-crcs* | Automatically check the CRC32 of the records consumed. This ensures no on-the-wire or on-disk corruption to the messages occurred. This check adds some overhead, so it may be disabled in cases seeking extreme performance. | true | Boolean | *camel.component.kafka.configuration.circular-topic-detection* | If the option is true, then KafkaProducer will detect if the message is attempted to be sent back to the same topic it may come from, if the message was original from a kafka consumer. If the KafkaConstants.TOPIC header is the same as the original kafka consumer topic, then the header setting is ignored, and the topic of the producer endpoint is used. In other words this avoids sending the same message back to where it came from. This option is not in use if the option bridgeEndpoint is set to true. | true | Boolean | *camel.component.kafka.configuration.client-id* | The client id is a user-specified string sent in each request to help trace calls. It should logically identify the application making the request. | | String | *camel.component.kafka.configuration.compression-codec* | This parameter allows you to specify the compression codec for all data generated by this producer. Valid values are ""none"", ""gzip"" and ""snappy"". | none | String | *camel.component.kafka.configuration.connection-max-idle-ms* | Close idle connections after the number of milliseconds specified by this config. | 540000 | Integer | *camel.component.kafka.configuration.consumer-request-timeout-ms* | The configuration controls the maximum amount of time the client will wait for the response of a request. If the response is not received before the timeout elapses the client will resend the request if necessary or fail the request if retries are exhausted. | 40000 | Integer | *camel.component.kafka.configuration.consumer-streams* | Number of concurrent consumers on the consumer | 10 | Integer | *camel.component.kafka.configuration.consumers-count* | The number of consumers that connect to kafka server | 1 | Integer | *camel.component.kafka.configuration.enable-idempotence* | If set to 'true' the producer will ensure that exactly one copy of each message is written in the stream. If 'false', producer retries may write duplicates of the retried message in the stream. If set to true this option will require max.in.flight.requests.per.connection to be set to 1 and retries cannot be zero and additionally acks must be set to 'all'. | false | Boolean | *camel.component.kafka.configuration.fetch-max-bytes* | The maximum amount of data the server should return for a fetch request This is not an absolute maximum, if the first message in the first non-empty partition of the fetch is larger than this value, the message will still be returned to ensure that the consumer can make progress. The maximum message size accepted by the broker is defined via message.max.bytes (broker config) or max.message.bytes (topic config). Note that the consumer performs multiple fetches in parallel. | 52428800 | Integer | *camel.component.kafka.configuration.fetch-min-bytes* | The minimum amount of data the server should return for a fetch request. If insufficient data is available the request will wait for that much data to accumulate before answering the request. | 1 | Integer | *camel.component.kafka.configuration.fetch-wait-max-ms* | The maximum amount of time the server will block before answering the fetch request if there isn't sufficient data to immediately satisfy fetch.min.bytes | 500 | Integer | *camel.component.kafka.configuration.group-id* | A string that uniquely identifies the group of consumer processes to which this consumer belongs. By setting the same group id multiple processes indicate that they are all part of the same consumer group. This option is required for consumers. | | String | *camel.component.kafka.configuration.header-filter-strategy* | To use a custom HeaderFilterStrategy to filter header to and from Camel message. | | HeaderFilterStrategy | *camel.component.kafka.configuration.heartbeat-interval-ms* | The expected time between heartbeats to the consumer coordinator when using Kafka's group management facilities. Heartbeats are used to ensure that the consumer's session stays active and to facilitate rebalancing when new consumers join or leave the group. The value must be set lower than session.timeout.ms, but typically should be set no higher than 1/3 of that value. It can be adjusted even lower to control the expected time for normal rebalances. | 3000 | Integer | *camel.component.kafka.configuration.interceptor-classes* | Sets interceptors for producer or consumers. Producer interceptors have to be classes implementing {@link org.apache.kafka.clients.producer.ProducerInterceptor} Consumer interceptors have to be classes implementing {@link org.apache.kafka.clients.consumer.ConsumerInterceptor} Note that if you use Producer interceptor on a consumer it will throw a class cast exception in runtime | | String | *camel.component.kafka.configuration.kafka-header-deserializer* | Sets custom KafkaHeaderDeserializer for deserialization kafka headers values to camel headers values. | | KafkaHeaderDeserializer | *camel.component.kafka.configuration.kafka-header-serializer* | Sets custom KafkaHeaderDeserializer for serialization camel headers values to kafka headers values. | | KafkaHeaderSerializer | *camel.component.kafka.configuration.kerberos-before-relogin-min-time* | Login thread sleep time between refresh attempts. | 60000 | Integer | *camel.component.kafka.configuration.kerberos-init-cmd* | Kerberos kinit command path. Default is /usr/bin/kinit | /usr/bin/kinit | String | *camel.component.kafka.configuration.kerberos-principal-to-local-rules* | A list of rules for mapping from principal names to short names (typically operating system usernames). The rules are evaluated in order and the first rule that matches a principal name is used to map it to a short name. Any later rules in the list are ignored. By default, principal names of the form {username}/{hostname}@{REALM} are mapped to {username}. For more details on the format please see the security authorization and acls documentation..

Multiple values can be separated by comma | DEFAULT | String | *camel.component.kafka.configuration.kerberos-renew-jitter* | Percentage of random jitter added to the renewal time. | 0.05 | Double | *camel.component.kafka.configuration.kerberos-renew-window-factor* | Login thread will sleep until the specified window factor of time from last refresh to ticket's expiry has been reached, at which time it will try to renew the ticket. | 0.8 | Double | *camel.component.kafka.configuration.key* | The record key (or null if no key is specified). If this option has been configured then it take precedence over header {@link KafkaConstants#KEY} | | String | *camel.component.kafka.configuration.key-deserializer* | Deserializer class for key that implements the Deserializer interface. | org.apache.kafka.common.serialization.StringDeserializer | String | *camel.component.kafka.configuration.key-serializer-class* | The serializer class for keys (defaults to the same as for messages if nothing is given). | org.apache.kafka.common.serialization.StringSerializer | String | *camel.component.kafka.configuration.linger-ms* | The producer groups together any records that arrive in between request transmissions into a single batched request. Normally this occurs only under load when records arrive faster than they can be sent out. However in some circumstances the client may want to reduce the number of requests even under moderate load. This setting accomplishes this by adding a small amount of artificial delay—that is, rather than immediately sending out a record the producer will wait for up to the given delay to allow other records to be sent so that the sends can be batched together. This can be thought of as analogous to Nagle's algorithm in TCP. This setting gives the upper bound on the delay for batching: once we get batch.size worth of records for a partition it will be sent immediately regardless of this setting, however if we have fewer than this many bytes accumulated for this partition we will 'linger' for the specified time waiting for more records to show up. This setting defaults to 0 (i.e. no delay). Setting linger.ms=5, for example, would have the effect of reducing the number of requests sent but would add up to 5ms of latency to records sent in the absense of load. | 0 | Integer | *camel.component.kafka.configuration.max-block-ms* | The configuration controls how long sending to kafka will block. These methods can be blocked for multiple reasons. For e.g: buffer full, metadata unavailable.This configuration imposes maximum limit on the total time spent in fetching metadata, serialization of key and value, partitioning and allocation of buffer memory when doing a send(). In case of partitionsFor(), this configuration imposes a maximum time threshold on waiting for metadata | 60000 | Integer | *camel.component.kafka.configuration.max-in-flight-request* | The maximum number of unacknowledged requests the client will send on a single connection before blocking. Note that if this setting is set to be greater than 1 and there are failed sends, there is a risk of message re-ordering due to retries (i.e., if retries are enabled). | 5 | Integer | *camel.component.kafka.configuration.max-partition-fetch-bytes* | The maximum amount of data per-partition the server will return. The maximum total memory used for a request will be #partitions * max.partition.fetch.bytes. This size must be at least as large as the maximum message size the server allows or else it is possible for the producer to send messages larger than the consumer can fetch. If that happens, the consumer can get stuck trying to fetch a large message on a certain partition. | 1048576 | Integer | *camel.component.kafka.configuration.max-poll-interval-ms* | The maximum delay between invocations of poll() when using consumer group management. This places an upper bound on the amount of time that the consumer can be idle before fetching more records. If poll() is not called before expiration of this timeout, then the consumer is considered failed and the group will rebalance in order to reassign the partitions to another member. | | Long | *camel.component.kafka.configuration.max-poll-records* | The maximum number of records returned in a single call to poll() | 500 | Integer | *camel.component.kafka.configuration.max-request-size* | The maximum size of a request. This is also effectively a cap on the maximum record size. Note that the server has its own cap on record size which may be different from this. This setting will limit the number of record batches the producer will send in a single request to avoid sending huge requests. | 1048576 | Integer | *camel.component.kafka.configuration.metadata-max-age-ms* | The period of time in milliseconds after which we force a refresh of metadata even if we haven't seen any partition leadership changes to proactively discover any new brokers or partitions. | 300000 | Integer | *camel.component.kafka.configuration.metric-reporters* | A list of classes to use as metrics reporters. Implementing the MetricReporter interface allows plugging in classes that will be notified of new metric creation. The JmxReporter is always included to register JMX statistics. | | String | *camel.component.kafka.configuration.metrics-sample-window-ms* | The number of samples maintained to compute metrics. | 30000 | Integer | *camel.component.kafka.configuration.no-of-metrics-sample* | The number of samples maintained to compute metrics. | 2 | Integer | *camel.component.kafka.configuration.offset-repository* | The offset repository to use in order to locally store the offset of each partition of the topic. Defining one will disable the autocommit. | | StateRepository | *camel.component.kafka.configuration.partition-assignor* | The class name of the partition assignment strategy that the client will use to distribute partition ownership amongst consumer instances when group management is used | org.apache.kafka.clients.consumer.RangeAssignor | String | *camel.component.kafka.configuration.partition-key* | The partition to which the record will be sent (or null if no partition was specified). If this option has been configured then it take precedence over header {@link KafkaConstants#PARTITION_KEY} | | Integer | *camel.component.kafka.configuration.partitioner* | The partitioner class for partitioning messages amongst sub-topics. The default partitioner is based on the hash of the key. | org.apache.kafka.clients.producer.internals.DefaultPartitioner | String | *camel.component.kafka.configuration.poll-timeout-ms* | The timeout used when polling the KafkaConsumer. | 5000 | Long | *camel.component.kafka.configuration.producer-batch-size* | The producer will attempt to batch records together into fewer requests whenever multiple records are being sent to the same partition. This helps performance on both the client and the server. This configuration controls the default batch size in bytes. No attempt will be made to batch records larger than this size.Requests sent to brokers will contain multiple batches, one for each partition with data available to be sent.A small batch size will make batching less common and may reduce throughput (a batch size of zero will disable batching entirely). A very large batch size may use memory a bit more wastefully as we will always allocate a buffer of the specified batch size in anticipation of additional records. | 16384 | Integer | *camel.component.kafka.configuration.queue-buffering-max-messages* | The maximum number of unsent messages that can be queued up the producer when using async mode before either the producer must be blocked or data must be dropped. | 10000 | Integer | *camel.component.kafka.configuration.receive-buffer-bytes* | The size of the TCP receive buffer (SO_RCVBUF) to use when reading data. | 65536 | Integer | *camel.component.kafka.configuration.reconnect-backoff-max-ms* | The maximum amount of time in milliseconds to wait when reconnecting to a broker that has repeatedly failed to connect. If provided, the backoff per host will increase exponentially for each consecutive connection failure, up to this maximum. After calculating the backoff increase, 20% random jitter is added to avoid connection storms. | 1000 | Integer | *camel.component.kafka.configuration.reconnect-backoff-ms* | The amount of time to wait before attempting to reconnect to a given host. This avoids repeatedly connecting to a host in a tight loop. This backoff applies to all requests sent by the consumer to the broker. | 50 | Integer | *camel.component.kafka.configuration.record-metadata* | Whether the producer should store the {@link RecordMetadata} results from sending to Kafka. The results are stored in a {@link List} containing the {@link RecordMetadata} metadata's. The list is stored on a header with the key {@link KafkaConstants#KAFKA_RECORDMETA} | true | Boolean | *camel.component.kafka.configuration.request-required-acks* | The number of acknowledgments the producer requires the leader to have received before considering a request complete. This controls the durability of records that are sent. The following settings are common: acks=0 If set to zero then the producer will not wait for any acknowledgment from the server at all. The record will be immediately added to the socket buffer and considered sent. No guarantee can be made that the server has received the record in this case, and the retries configuration will not take effect (as the client won't generally know of any failures). The offset given back for each record will always be set to -1. acks=1 This will mean the leader will write the record to its local log but will respond without awaiting full acknowledgement from all followers. In this case should the leader fail immediately after acknowledging the record but before the followers have replicated it then the record will be lost. acks=all This means the leader will wait for the full set of in-sync replicas to acknowledge the record. This guarantees that the record will not be lost as long as at least one in-sync replica remains alive. This is the strongest available guarantee. | 1 | String | *camel.component.kafka.configuration.request-timeout-ms* | The amount of time the broker will wait trying to meet the request.required.acks requirement before sending back an error to the client. | 305000 | Integer | *camel.component.kafka.configuration.retries* | Setting a value greater than zero will cause the client to resend any record whose send fails with a potentially transient error. Note that this retry is no different than if the client resent the record upon receiving the error. Allowing retries will potentially change the ordering of records because if two records are sent to a single partition, and the first fails and is retried but the second succeeds, then the second record may appear first. | 0 | Integer | *camel.component.kafka.configuration.retry-backoff-ms* | Before each retry, the producer refreshes the metadata of relevant topics to see if a new leader has been elected. Since leader election takes a bit of time, this property specifies the amount of time that the producer waits before refreshing the metadata. | 100 | Integer | *camel.component.kafka.configuration.sasl-jaas-config* | Expose the kafka sasl.jaas.config parameter Example: org.apache.kafka.common.security.plain.PlainLoginModule required username=""USERNAME"" password=""PASSWORD""; | | String | *camel.component.kafka.configuration.sasl-kerberos-service-name* | The Kerberos principal name that Kafka runs as. This can be defined either in Kafka's JAAS config or in Kafka's config. | | String | *camel.component.kafka.configuration.sasl-mechanism* | The Simple Authentication and Security Layer (SASL) Mechanism used. For the valid values see http://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml | GSSAPI | String | *camel.component.kafka.configuration.schema-registry-u-r-l* | URL of the Confluent schema registry servers to use. The format is host1:port1,host2:port2. This is known as schema.registry.url in the Confluent documentation.

This option is only available in the Confluent Kafka product (not standard Apache Kafka) | | String | *camel.component.kafka.configuration.security-protocol* | Protocol used to communicate with brokers. SASL_PLAINTEXT, PLAINTEXT and SSL are supported | PLAINTEXT | String | *camel.component.kafka.configuration.seek-to* | Set if KafkaConsumer will read from beginning or end on startup: beginning : read from beginning end : read from end This is replacing the earlier property seekToBeginning | | String | *camel.component.kafka.configuration.send-buffer-bytes* | Socket write buffer size | 131072 | Integer | *camel.component.kafka.configuration.serializer-class* | The serializer class for messages. | org.apache.kafka.common.serialization.StringSerializer | String | *camel.component.kafka.configuration.session-timeout-ms* | The timeout used to detect failures when using Kafka's group management facilities. | 10000 | Integer | *camel.component.kafka.configuration.ssl-cipher-suites* | A list of cipher suites. This is a named combination of authentication, encryption, MAC and key exchange algorithm used to negotiate the security settings for a network connection using TLS or SSL network protocol.By default all the available cipher suites are supported. | | String | *camel.component.kafka.configuration.ssl-context-parameters* | SSL configuration using a Camel {@link SSLContextParameters} object. If configured it's applied before the other SSL endpoint parameters. | | SSLContextParameters | *camel.component.kafka.configuration.ssl-enabled-protocols* | The list of protocols enabled for SSL connections. TLSv1.2, TLSv1.1 and TLSv1 are enabled by default. | TLSv1.2,TLSv1.1,TLSv1 | String | *camel.component.kafka.configuration.ssl-endpoint-algorithm* | The endpoint identification algorithm to validate server hostname using server certificate. | | String | *camel.component.kafka.configuration.ssl-key-password* | The password of the private key in the key store file. This is optional for client. | | String | *camel.component.kafka.configuration.ssl-keymanager-algorithm* | The algorithm used by key manager factory for SSL connections. Default value is the key manager factory algorithm configured for the Java Virtual Machine. | SunX509 | String | *camel.component.kafka.configuration.ssl-keystore-location* | The location of the key store file. This is optional for client and can be used for two-way authentication for client. | | String | *camel.component.kafka.configuration.ssl-keystore-password* | The store password for the key store file.This is optional for client and only needed if ssl.keystore.location is configured. | | String | *camel.component.kafka.configuration.ssl-keystore-type* | The file format of the key store file. This is optional for client. Default value is JKS | JKS | String | *camel.component.kafka.configuration.ssl-protocol* | The SSL protocol used to generate the SSLContext. Default setting is TLS, which is fine for most cases. Allowed values in recent JVMs are TLS, TLSv1.1 and TLSv1.2. SSL, SSLv2 and SSLv3 may be supported in older JVMs, but their usage is discouraged due to known security vulnerabilities. | TLS | String | *camel.component.kafka.configuration.ssl-provider* | The name of the security provider used for SSL connections. Default value is the default security provider of the JVM. | | String | *camel.component.kafka.configuration.ssl-trustmanager-algorithm* | The algorithm used by trust manager factory for SSL connections. Default value is the trust manager factory algorithm configured for the Java Virtual Machine. | PKIX | String | *camel.component.kafka.configuration.ssl-truststore-location* | The location of the trust store file. | | String | *camel.component.kafka.configuration.ssl-truststore-password* | The password for the trust store file. | | String | *camel.component.kafka.configuration.ssl-truststore-type* | The file format of the trust store file. Default value is JKS. | JKS | String | *camel.component.kafka.configuration.specificAvroReader* | This enables the use of a specific Avro reader for use with the Confluent schema registry and the io.confluent.kafka.serializers.KafkaAvroDeserializer. The default value is false. | false | boolean | *camel.component.kafka.configuration.topic* | Name of the topic to use. On the consumer you can use comma to separate multiple topics. A producer can only send a message to a single topic. | | String | *camel.component.kafka.configuration.topic-is-pattern* | Whether the topic is a pattern (regular expression). This can be used to subscribe to dynamic number of topics matching the pattern. | false | Boolean | *camel.component.kafka.configuration.value-deserializer* | Deserializer class for value that implements the Deserializer interface. | org.apache.kafka.common.serialization.StringDeserializer | String | *camel.component.kafka.configuration.worker-pool* | To use a custom worker pool for continue routing {@link Exchange} after kafka server has acknowledge the message that was sent to it from {@link KafkaProducer} using asynchronous non-blocking processing. | | ExecutorService | *camel.component.kafka.configuration.worker-pool-core-size* | Number of core threads for the worker pool for continue routing {@link Exchange} after kafka server has acknowledge the message that was sent to it from {@link KafkaProducer} using asynchronous non-blocking processing. | 10 | Integer | *camel.component.kafka.configuration.worker-pool-max-size* | Maximum number of threads for the worker pool for continue routing {@link Exchange} after kafka server has acknowledge the message that was sent to it from {@link KafkaProducer} using asynchronous non-blocking processing. | 20 | Integer | *camel.component.kafka.enabled* | Enable kafka component | true | Boolean | *camel.component.kafka.kafka-manual-commit-factory* | Factory to use for creating KafkaManualCommit instances. This allows to plugin a custom factory to create custom KafkaManualCommit instances in case special logic is needed when doing manual commits that deviates from the default implementation that comes out of the box. The option is a org.apache.camel.component.kafka.KafkaManualCommitFactory type. | | String | *camel.component.kafka.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean | *camel.component.kafka.use-global-ssl-context-parameters* | Enable usage of global SSL context parameters. | false | Boolean | *camel.component.kafka.worker-pool* | To use a shared custom worker pool for continue routing Exchange after kafka server has acknowledge the message that was sent to it from KafkaProducer using asynchronous non-blocking processing. If using this option then you must handle the lifecycle of the thread pool to shut the pool down when no longer needed. The option is a java.util.concurrent.ExecutorService type. | | String |=== // spring-boot-auto-configure options: END For more information about Producer/Consumer configuration: http://kafka.apache.org/documentation.html#newconsumerconfigs[http://kafka.apache.org/documentation.html#newconsumerconfigs] http://kafka.apache.org/documentation.html#producerconfigs[http://kafka.apache.org/documentation.html#producerconfigs] === Message headers ==== Consumer headers The following headers are available when consuming messages from Kafka. [width=""100%"",cols=""2m,2m,1m,5"",options=""header""] |=== | Header constant | Header value | Type | Description | KafkaConstants.TOPIC | ""kafka.TOPIC"" | String | The topic from where the message originated | KafkaConstants.PARTITION | ""kafka.PARTITION"" | Integer | The partition where the message was stored | KafkaConstants.OFFSET | ""kafka.OFFSET"" | Long | The offset of the message | KafkaConstants.KEY | ""kafka.KEY"" | Object | The key of the message if configured | KafkaConstants.HEADERS | ""kafka.HEADERS"" | org.apache.kafka.common.header.Headers | The record headers | KafkaConstants.LAST_RECORD_BEFORE_COMMIT | ""kafka.LAST_RECORD_BEFORE_COMMIT"" | Boolean | Whether or not it's the last record before commit (only available if `autoCommitEnable` endpoint parameter is `false`) | KafkaConstants.MANUAL_COMMIT | ""CamelKafkaManualCommit"" | KafkaManualCommit | Can be used for forcing manual offset commit when using Kafka consumer. | |=== ==== Producer headers Before sending a message to Kafka you can configure the following headers. [width=""100%"",cols=""2m,2m,1m,5"",options=""header""] |=== | Header constant | Header value | Type | Description | KafkaConstants.KEY | ""kafka.KEY"" | Object | *Required* The key of the message in order to ensure that all related message goes in the same partition | KafkaConstants.TOPIC | ""kafka.TOPIC"" | String | The topic to which send the message (only read if the `bridgeEndpoint` endpoint parameter is `true`) | KafkaConstants.PARTITION_KEY | ""kafka.PARTITION_KEY"" | Integer | Explicitly specify the partition (only used if the `KafkaConstants.KEY` header is defined) |=== After the message is sent to Kafka, the following headers are available [width=""100%"",cols=""2m,2m,1m,5"",options=""header""] |=== | Header constant | Header value | Type | Description | KafkaConstants.KAFKA_RECORDMETA | ""org.apache.kafka.clients.producer.RecordMetadata"" | List | The metadata (only configured if `recordMetadata` endpoint parameter is `true` |=== === Samples ==== Consuming messages from Kafka Here is the minimal route you need in order to read messages from Kafka. [source,java] ---- from(""kafka:test?brokers=localhost:9092"") .log(""Message received from Kafka : ${body}"") .log("" on the topic ${headers[kafka.TOPIC]}"") .log("" on the partition ${headers[kafka.PARTITION]}"") .log("" with the offset ${headers[kafka.OFFSET]}"") .log("" with the key ${headers[kafka.KEY]}"") ---- If you need to consume messages from multiple topics you can use a comma separated list of topic names [source,java] ---- from(""kafka:test,test1,test2?brokers=localhost:9092"") .log(""Message received from Kafka : ${body}"") .log("" on the topic ${headers[kafka.TOPIC]}"") .log("" on the partition ${headers[kafka.PARTITION]}"") .log("" with the offset ${headers[kafka.OFFSET]}"") .log("" with the key ${headers[kafka.KEY]}"") ---- When consuming messages from Kafka you can use your own offset management and not delegate this management to Kafka. In order to keep the offsets the component needs a `StateRepository` implementation such as `FileStateRepository`. This bean should be available in the registry. Here how to use it : [source,java] ---- // Create the repository in which the Kafka offsets will be persisted FileStateRepository repository = FileStateRepository.fileStateRepository(new File(""/path/to/repo.dat"")); // Bind this repository into the Camel registry JndiRegistry registry = new JndiRegistry(); registry.bind(""offsetRepo"", repository); // Configure the camel context DefaultCamelContext camelContext = new DefaultCamelContext(registry); camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from(""kafka:"" + TOPIC + ""?brokers=localhost:{{kafkaPort}}"" + // Setup the topic and broker address ""&groupId=A"" + // The consumer processor group ID ""&autoOffsetReset=earliest"" + // Ask to start from the beginning if we have unknown offset ""&offsetRepository=#offsetRepo"") // Keep the offsets in the previously configured repository .to(""mock:result""); } }); ----   ==== Producing messages to Kafka Here is the minimal route you need in order to write messages to Kafka. [source,java] ---- from(""direct:start"") .setBody(constant(""Message from Camel"")) // Message to send .setHeader(KafkaConstants.KEY, constant(""Camel"")) // Key of the message .to(""kafka:test?brokers=localhost:9092""); ---- === SSL configuration You have 2 different ways to configure the SSL communication on the Kafka` component. The first way is through the many SSL endpoint parameters [source,java] ---- from(""kafka:"" + TOPIC + ""?brokers=localhost:{{kafkaPort}}"" + ""&groupId=A"" + ""&sslKeystoreLocation=/path/to/keystore.jks"" + ""&sslKeystorePassword=changeit"" + ""&sslKeyPassword=changeit"" + ""&securityProtocol=SSL"") .to(""mock:result""); ---- The second way is to use the `sslContextParameters` endpoint parameter. [source,java] ---- // Configure the SSLContextParameters object KeyStoreParameters ksp = new KeyStoreParameters(); ksp.setResource(""/path/to/keystore.jks""); ksp.setPassword(""changeit""); KeyManagersParameters kmp = new KeyManagersParameters(); kmp.setKeyStore(ksp); kmp.setKeyPassword(""changeit""); SSLContextParameters scp = new SSLContextParameters(); scp.setKeyManagers(kmp); // Bind this SSLContextParameters into the Camel registry JndiRegistry registry = new JndiRegistry(); registry.bind(""ssl"", scp); // Configure the camel context DefaultCamelContext camelContext = new DefaultCamelContext(registry); camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from(""kafka:"" + TOPIC + ""?brokers=localhost:{{kafkaPort}}"" + // Setup the topic and broker address ""&groupId=A"" + // The consumer processor group ID ""&sslContextParameters=#ssl"" + // The security protocol ""&securityProtocol=SSL) // Reference the SSL configuration .to(""mock:result""); } }); ---- === Using the Kafka idempotent repository *Available from Camel 2.19* The `camel-kafka` library provides a Kafka topic-based idempotent repository. This repository stores broadcasts all changes to idempotent state (add/remove) in a Kafka topic, and populates a local in-memory cache for each repository's process instance through event sourcing. The topic used must be unique per idempotent repository instance. The mechanism does not have any requirements about the number of topic partitions; as the repository consumes from all partitions at the same time. It also does not have any requirements about the replication factor of the topic. Each repository instance that uses the topic (e.g. typically on different machines running in parallel) controls its own consumer group, so in a cluster of 10 Camel processes using the same topic each will control its own offset. On startup, the instance subscribes to the topic and rewinds the offset to the beginning, rebuilding the cache to the latest state. The cache will not be considered warmed up until one poll of `pollDurationMs` in length returns 0 records. Startup will not be completed until either the cache has warmed up, or 30 seconds go by; if the latter happens the idempotent repository may be in an inconsistent state until its consumer catches up to the end of the topic. A `KafkaIdempotentRepository` has the following properties: [width=""100%"",cols=""2m,5"",options=""header""] |=== | Property | Description | topic | The name of the Kafka topic to use to broadcast changes. (required) | bootstrapServers | The `bootstrap.servers` property on the internal Kafka producer and consumer. Use this as shorthand if not setting `consumerConfig` and `producerConfig`. If used, this component will apply sensible default configurations for the producer and consumer. | producerConfig | Sets the properties that will be used by the Kafka producer that broadcasts changes. Overrides `bootstrapServers`, so must define the Kafka `bootstrap.servers` property itself | consumerConfig | Sets the properties that will be used by the Kafka consumer that populates the cache from the topic. Overrides `bootstrapServers`, so must define the Kafka `bootstrap.servers` property itself | maxCacheSize | How many of the most recently used keys should be stored in memory (default 1000). | pollDurationMs | The poll duration of the Kafka consumer. The local caches are updated immediately. This value will affect how far behind other peers that update their caches from the topic are relative to the idempotent consumer instance that sent the cache action message. The default value of this is 100 ms. + If setting this value explicitly, be aware that there is a tradeoff between the remote cache liveness and the volume of network traffic between this repository's consumer and the Kafka brokers. The cache warmup process also depends on there being one poll that fetches nothing - this indicates that the stream has been consumed up to the current point. If the poll duration is excessively long for the rate at which messages are sent on the topic, there exists a possibility that the cache cannot be warmed up and will operate in an inconsistent state relative to its peers until it catches up. |=== The repository can be instantiated by defining the `topic` and `bootstrapServers`, or the `producerConfig` and `consumerConfig` property sets can be explicitly defined to enable features such as SSL/SASL. To use, this repository must be placed in the Camel registry, either manually or by registration as a bean in Spring/Blueprint, as it is `CamelContext` aware. Sample usage is as follows: [source,java] ---- KafkaIdempotentRepository kafkaIdempotentRepository = new KafkaIdempotentRepository(""idempotent-db-inserts"", ""localhost:9091""); SimpleRegistry registry = new SimpleRegistry(); registry.put(""insertDbIdemRepo"", kafkaIdempotentRepository); // must be registered in the registry, to enable access to the CamelContext CamelContext context = new CamelContext(registry); // later in RouteBuilder... from(""direct:performInsert"") .idempotentConsumer(header(""id"")).messageIdRepositoryRef(""insertDbIdemRepo"") // once-only insert into database .end() ---- In XML: [source,xml] ---- localhost:9091 localhost:9091 ---- === Using manual commit with Kafka consumer *Available as of Camel 2.21* By default the Kafka consumer will use auto commit, where the offset will be committed automatically in the background using a given interval. In case you want to force manual commits, you can use `KafkaManualCommit` API from the Camel Exchange, stored on the message header. This requires to turn on manual commits by either setting the option `allowManualCommit` to `true` on the `KafkaComponent` or on the endpoint, for example: [source,java] ---- KafkaComponent kafka = new KafkaComponent(); kafka.setAllowManualCommit(true); ... camelContext.addComponent(""kafka"", kafka); ---- You can then use the `KafkaManualCommit` from Java code such as a Camel `Processor`: [source,java] ---- public void process(Exchange exchange) { KafkaManualCommit manual = exchange.getIn().getHeader(KafkaConstants.MANUAL_COMMIT, KafkaManualCommit.class); manual.commitSync(); } ---- This will force a synchronous commit which will block until the commit is acknowledge on Kafka, or if it fails an exception is thrown. If you want to use a custom implementation of `KafkaManualCommit` then you can configure a custom `KafkaManualCommitFactory` on the `KafkaComponent` that creates instances of your custom implementation. === Kafka Headers propagation *Available as of Camel 2.22* When consuming messages from Kafka, headers will be propagated to camel exchange headers automatically. Producing flow backed by same behaviour - camel headers of particular exchange will be propagated to kafka message headers. Since kafka headers allows only `byte[]` values, in order camel exchnage header to be propagated its value should be serialized to `bytes[]`, otherwise header will be skipped. Following header value types are supported: `String`, `Integer`, `Long`, `Double`, `Boolean`, `byte[]`. Note: all headers propagated *from* kafka *to* camel exchange will contain `byte[]` value by default. In order to override default functionality uri parameters can be set: `kafkaHeaderDeserializer` for `from` route and `kafkaHeaderSerializer` for `to` route. Example: ``` from(""kafka:my_topic?kafkaHeaderDeserializer=#myDeserializer"") ... .to(""kafka:my_topic?kafkaHeaderSerializer=#mySerializer"") ``` By default all headers are being filtered by `KafkaHeaderFilterStrategy`. Strategy filters out headers which start with `Camel` or `org.apache.camel` prefixes. Default strategy can be overridden by using `headerFilterStrategy` uri parameter in both `to` and `from` routes: ``` from(""kafka:my_topic?headerFilterStrategy=#myStrategy"") ... .to(""kafka:my_topic?headerFilterStrategy=#myStrategy"") ``` `myStrategy` object should be subclass of `HeaderFilterStrategy` and must be placed in the Camel registry, either manually or by registration as a bean in Spring/Blueprint, as it is `CamelContext` aware. ",16310,True,3469.2570357447653,median "-- This spec has been automatically generated from STM32F303xE.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.RTC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype TR_SU_Field is STM32_SVD.UInt4; subtype TR_ST_Field is STM32_SVD.UInt3; subtype TR_MNU_Field is STM32_SVD.UInt4; subtype TR_MNT_Field is STM32_SVD.UInt3; subtype TR_HU_Field is STM32_SVD.UInt4; subtype TR_HT_Field is STM32_SVD.UInt2; subtype TR_PM_Field is STM32_SVD.Bit; -- time register type TR_Register is record -- Second units in BCD format SU : TR_SU_Field := 16#0#; -- Second tens in BCD format ST : TR_ST_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Minute units in BCD format MNU : TR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : TR_MNT_Field := 16#0#; -- unspecified Reserved_15_15 : STM32_SVD.Bit := 16#0#; -- Hour units in BCD format HU : TR_HU_Field := 16#0#; -- Hour tens in BCD format HT : TR_HT_Field := 16#0#; -- AM/PM notation PM : TR_PM_Field := 16#0#; -- unspecified Reserved_23_31 : STM32_SVD.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype DR_DU_Field is STM32_SVD.UInt4; subtype DR_DT_Field is STM32_SVD.UInt2; subtype DR_MU_Field is STM32_SVD.UInt4; subtype DR_MT_Field is STM32_SVD.Bit; subtype DR_WDU_Field is STM32_SVD.UInt3; subtype DR_YU_Field is STM32_SVD.UInt4; subtype DR_YT_Field is STM32_SVD.UInt4; -- date register type DR_Register is record -- Date units in BCD format DU : DR_DU_Field := 16#1#; -- Date tens in BCD format DT : DR_DT_Field := 16#0#; -- unspecified Reserved_6_7 : STM32_SVD.UInt2 := 16#0#; -- Month units in BCD format MU : DR_MU_Field := 16#1#; -- Month tens in BCD format MT : DR_MT_Field := 16#0#; -- Week day units WDU : DR_WDU_Field := 16#1#; -- Year units in BCD format YU : DR_YU_Field := 16#0#; -- Year tens in BCD format YT : DR_YT_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DR_Register use record DU at 0 range 0 .. 3; DT at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; MU at 0 range 8 .. 11; MT at 0 range 12 .. 12; WDU at 0 range 13 .. 15; YU at 0 range 16 .. 19; YT at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype CR_WCKSEL_Field is STM32_SVD.UInt3; subtype CR_TSEDGE_Field is STM32_SVD.Bit; subtype CR_REFCKON_Field is STM32_SVD.Bit; subtype CR_BYPSHAD_Field is STM32_SVD.Bit; subtype CR_FMT_Field is STM32_SVD.Bit; subtype CR_ALRAE_Field is STM32_SVD.Bit; subtype CR_ALRBE_Field is STM32_SVD.Bit; subtype CR_WUTE_Field is STM32_SVD.Bit; subtype CR_TSE_Field is STM32_SVD.Bit; subtype CR_ALRAIE_Field is STM32_SVD.Bit; subtype CR_ALRBIE_Field is STM32_SVD.Bit; subtype CR_WUTIE_Field is STM32_SVD.Bit; subtype CR_TSIE_Field is STM32_SVD.Bit; subtype CR_ADD1H_Field is STM32_SVD.Bit; subtype CR_SUB1H_Field is STM32_SVD.Bit; subtype CR_BKP_Field is STM32_SVD.Bit; subtype CR_COSEL_Field is STM32_SVD.Bit; subtype CR_POL_Field is STM32_SVD.Bit; subtype CR_OSEL_Field is STM32_SVD.UInt2; subtype CR_COE_Field is STM32_SVD.Bit; -- control register type CR_Register is record -- Wakeup clock selection WCKSEL : CR_WCKSEL_Field := 16#0#; -- Time-stamp event active edge TSEDGE : CR_TSEDGE_Field := 16#0#; -- Reference clock detection enable (50 or 60 Hz) REFCKON : CR_REFCKON_Field := 16#0#; -- Bypass the shadow registers BYPSHAD : CR_BYPSHAD_Field := 16#0#; -- Hour format FMT : CR_FMT_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Alarm A enable ALRAE : CR_ALRAE_Field := 16#0#; -- Alarm B enable ALRBE : CR_ALRBE_Field := 16#0#; -- Wakeup timer enable WUTE : CR_WUTE_Field := 16#0#; -- Time stamp enable TSE : CR_TSE_Field := 16#0#; -- Alarm A interrupt enable ALRAIE : CR_ALRAIE_Field := 16#0#; -- Alarm B interrupt enable ALRBIE : CR_ALRBIE_Field := 16#0#; -- Wakeup timer interrupt enable WUTIE : CR_WUTIE_Field := 16#0#; -- Time-stamp interrupt enable TSIE : CR_TSIE_Field := 16#0#; -- Add 1 hour (summer time change) ADD1H : CR_ADD1H_Field := 16#0#; -- Subtract 1 hour (winter time change) SUB1H : CR_SUB1H_Field := 16#0#; -- Backup BKP : CR_BKP_Field := 16#0#; -- Calibration output selection COSEL : CR_COSEL_Field := 16#0#; -- Output polarity POL : CR_POL_Field := 16#0#; -- Output selection OSEL : CR_OSEL_Field := 16#0#; -- Calibration output enable COE : CR_COE_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record WCKSEL at 0 range 0 .. 2; TSEDGE at 0 range 3 .. 3; REFCKON at 0 range 4 .. 4; BYPSHAD at 0 range 5 .. 5; FMT at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; ALRAE at 0 range 8 .. 8; ALRBE at 0 range 9 .. 9; WUTE at 0 range 10 .. 10; TSE at 0 range 11 .. 11; ALRAIE at 0 range 12 .. 12; ALRBIE at 0 range 13 .. 13; WUTIE at 0 range 14 .. 14; TSIE at 0 range 15 .. 15; ADD1H at 0 range 16 .. 16; SUB1H at 0 range 17 .. 17; BKP at 0 range 18 .. 18; COSEL at 0 range 19 .. 19; POL at 0 range 20 .. 20; OSEL at 0 range 21 .. 22; COE at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype ISR_ALRAWF_Field is STM32_SVD.Bit; subtype ISR_ALRBWF_Field is STM32_SVD.Bit; subtype ISR_WUTWF_Field is STM32_SVD.Bit; subtype ISR_SHPF_Field is STM32_SVD.Bit; subtype ISR_INITS_Field is STM32_SVD.Bit; subtype ISR_RSF_Field is STM32_SVD.Bit; subtype ISR_INITF_Field is STM32_SVD.Bit; subtype ISR_INIT_Field is STM32_SVD.Bit; subtype ISR_ALRAF_Field is STM32_SVD.Bit; subtype ISR_ALRBF_Field is STM32_SVD.Bit; subtype ISR_WUTF_Field is STM32_SVD.Bit; subtype ISR_TSF_Field is STM32_SVD.Bit; subtype ISR_TSOVF_Field is STM32_SVD.Bit; subtype ISR_TAMP1F_Field is STM32_SVD.Bit; subtype ISR_TAMP2F_Field is STM32_SVD.Bit; subtype ISR_TAMP3F_Field is STM32_SVD.Bit; subtype ISR_RECALPF_Field is STM32_SVD.Bit; -- initialization and status register type ISR_Register is record -- Read-only. Alarm A write flag ALRAWF : ISR_ALRAWF_Field := 16#1#; -- Read-only. Alarm B write flag ALRBWF : ISR_ALRBWF_Field := 16#1#; -- Read-only. Wakeup timer write flag WUTWF : ISR_WUTWF_Field := 16#1#; -- Shift operation pending SHPF : ISR_SHPF_Field := 16#0#; -- Read-only. Initialization status flag INITS : ISR_INITS_Field := 16#0#; -- Registers synchronization flag RSF : ISR_RSF_Field := 16#0#; -- Read-only. Initialization flag INITF : ISR_INITF_Field := 16#0#; -- Initialization mode INIT : ISR_INIT_Field := 16#0#; -- Alarm A flag ALRAF : ISR_ALRAF_Field := 16#0#; -- Alarm B flag ALRBF : ISR_ALRBF_Field := 16#0#; -- Wakeup timer flag WUTF : ISR_WUTF_Field := 16#0#; -- Time-stamp flag TSF : ISR_TSF_Field := 16#0#; -- Time-stamp overflow flag TSOVF : ISR_TSOVF_Field := 16#0#; -- Tamper detection flag TAMP1F : ISR_TAMP1F_Field := 16#0#; -- RTC_TAMP2 detection flag TAMP2F : ISR_TAMP2F_Field := 16#0#; -- RTC_TAMP3 detection flag TAMP3F : ISR_TAMP3F_Field := 16#0#; -- Read-only. Recalibration pending Flag RECALPF : ISR_RECALPF_Field := 16#0#; -- unspecified Reserved_17_31 : STM32_SVD.UInt15 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register use record ALRAWF at 0 range 0 .. 0; ALRBWF at 0 range 1 .. 1; WUTWF at 0 range 2 .. 2; SHPF at 0 range 3 .. 3; INITS at 0 range 4 .. 4; RSF at 0 range 5 .. 5; INITF at 0 range 6 .. 6; INIT at 0 range 7 .. 7; ALRAF at 0 range 8 .. 8; ALRBF at 0 range 9 .. 9; WUTF at 0 range 10 .. 10; TSF at 0 range 11 .. 11; TSOVF at 0 range 12 .. 12; TAMP1F at 0 range 13 .. 13; TAMP2F at 0 range 14 .. 14; TAMP3F at 0 range 15 .. 15; RECALPF at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; subtype PRER_PREDIV_S_Field is STM32_SVD.UInt15; subtype PRER_PREDIV_A_Field is STM32_SVD.UInt7; -- prescaler register type PRER_Register is record -- Synchronous prescaler factor PREDIV_S : PRER_PREDIV_S_Field := 16#FF#; -- unspecified Reserved_15_15 : STM32_SVD.Bit := 16#0#; -- Asynchronous prescaler factor PREDIV_A : PRER_PREDIV_A_Field := 16#7F#; -- unspecified Reserved_23_31 : STM32_SVD.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PRER_Register use record PREDIV_S at 0 range 0 .. 14; Reserved_15_15 at 0 range 15 .. 15; PREDIV_A at 0 range 16 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype WUTR_WUT_Field is STM32_SVD.UInt16; -- wakeup timer register type WUTR_Register is record -- Wakeup auto-reload value bits WUT : WUTR_WUT_Field := 16#FFFF#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for WUTR_Register use record WUT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype ALRMAR_SU_Field is STM32_SVD.UInt4; subtype ALRMAR_ST_Field is STM32_SVD.UInt3; subtype ALRMAR_MSK1_Field is STM32_SVD.Bit; subtype ALRMAR_MNU_Field is STM32_SVD.UInt4; subtype ALRMAR_MNT_Field is STM32_SVD.UInt3; subtype ALRMAR_MSK2_Field is STM32_SVD.Bit; subtype ALRMAR_HU_Field is STM32_SVD.UInt4; subtype ALRMAR_HT_Field is STM32_SVD.UInt2; subtype ALRMAR_PM_Field is STM32_SVD.Bit; subtype ALRMAR_MSK3_Field is STM32_SVD.Bit; subtype ALRMAR_DU_Field is STM32_SVD.UInt4; subtype ALRMAR_DT_Field is STM32_SVD.UInt2; subtype ALRMAR_WDSEL_Field is STM32_SVD.Bit; subtype ALRMAR_MSK4_Field is STM32_SVD.Bit; -- alarm A register type ALRMAR_Register is record -- Second units in BCD format SU : ALRMAR_SU_Field := 16#0#; -- Second tens in BCD format ST : ALRMAR_ST_Field := 16#0#; -- Alarm A seconds mask MSK1 : ALRMAR_MSK1_Field := 16#0#; -- Minute units in BCD format MNU : ALRMAR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : ALRMAR_MNT_Field := 16#0#; -- Alarm A minutes mask MSK2 : ALRMAR_MSK2_Field := 16#0#; -- Hour units in BCD format HU : ALRMAR_HU_Field := 16#0#; -- Hour tens in BCD format HT : ALRMAR_HT_Field := 16#0#; -- AM/PM notation PM : ALRMAR_PM_Field := 16#0#; -- Alarm A hours mask MSK3 : ALRMAR_MSK3_Field := 16#0#; -- Date units or day in BCD format DU : ALRMAR_DU_Field := 16#0#; -- Date tens in BCD format DT : ALRMAR_DT_Field := 16#0#; -- Week day selection WDSEL : ALRMAR_WDSEL_Field := 16#0#; -- Alarm A date mask MSK4 : ALRMAR_MSK4_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMAR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; MSK1 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; MSK2 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; MSK3 at 0 range 23 .. 23; DU at 0 range 24 .. 27; DT at 0 range 28 .. 29; WDSEL at 0 range 30 .. 30; MSK4 at 0 range 31 .. 31; end record; subtype ALRMBR_SU_Field is STM32_SVD.UInt4; subtype ALRMBR_ST_Field is STM32_SVD.UInt3; subtype ALRMBR_MSK1_Field is STM32_SVD.Bit; subtype ALRMBR_MNU_Field is STM32_SVD.UInt4; subtype ALRMBR_MNT_Field is STM32_SVD.UInt3; subtype ALRMBR_MSK2_Field is STM32_SVD.Bit; subtype ALRMBR_HU_Field is STM32_SVD.UInt4; subtype ALRMBR_HT_Field is STM32_SVD.UInt2; subtype ALRMBR_PM_Field is STM32_SVD.Bit; subtype ALRMBR_MSK3_Field is STM32_SVD.Bit; subtype ALRMBR_DU_Field is STM32_SVD.UInt4; subtype ALRMBR_DT_Field is STM32_SVD.UInt2; subtype ALRMBR_WDSEL_Field is STM32_SVD.Bit; subtype ALRMBR_MSK4_Field is STM32_SVD.Bit; -- alarm B register type ALRMBR_Register is record -- Second units in BCD format SU : ALRMBR_SU_Field := 16#0#; -- Second tens in BCD format ST : ALRMBR_ST_Field := 16#0#; -- Alarm B seconds mask MSK1 : ALRMBR_MSK1_Field := 16#0#; -- Minute units in BCD format MNU : ALRMBR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : ALRMBR_MNT_Field := 16#0#; -- Alarm B minutes mask MSK2 : ALRMBR_MSK2_Field := 16#0#; -- Hour units in BCD format HU : ALRMBR_HU_Field := 16#0#; -- Hour tens in BCD format HT : ALRMBR_HT_Field := 16#0#; -- AM/PM notation PM : ALRMBR_PM_Field := 16#0#; -- Alarm B hours mask MSK3 : ALRMBR_MSK3_Field := 16#0#; -- Date units or day in BCD format DU : ALRMBR_DU_Field := 16#0#; -- Date tens in BCD format DT : ALRMBR_DT_Field := 16#0#; -- Week day selection WDSEL : ALRMBR_WDSEL_Field := 16#0#; -- Alarm B date mask MSK4 : ALRMBR_MSK4_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMBR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; MSK1 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; MSK2 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; MSK3 at 0 range 23 .. 23; DU at 0 range 24 .. 27; DT at 0 range 28 .. 29; WDSEL at 0 range 30 .. 30; MSK4 at 0 range 31 .. 31; end record; subtype WPR_KEY_Field is STM32_SVD.Byte; -- write protection register type WPR_Register is record -- Write-only. Write protection key KEY : WPR_KEY_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for WPR_Register use record KEY at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype SSR_SS_Field is STM32_SVD.UInt16; -- sub second register type SSR_Register is record -- Read-only. Sub second value SS : SSR_SS_Field; -- unspecified Reserved_16_31 : STM32_SVD.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SSR_Register use record SS at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SHIFTR_SUBFS_Field is STM32_SVD.UInt15; subtype SHIFTR_ADD1S_Field is STM32_SVD.Bit; -- shift control register type SHIFTR_Register is record -- Write-only. Subtract a fraction of a second SUBFS : SHIFTR_SUBFS_Field := 16#0#; -- unspecified Reserved_15_30 : STM32_SVD.UInt16 := 16#0#; -- Write-only. Add one second ADD1S : SHIFTR_ADD1S_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SHIFTR_Register use record SUBFS at 0 range 0 .. 14; Reserved_15_30 at 0 range 15 .. 30; ADD1S at 0 range 31 .. 31; end record; subtype TSTR_SU_Field is STM32_SVD.UInt4; subtype TSTR_ST_Field is STM32_SVD.UInt3; subtype TSTR_MNU_Field is STM32_SVD.UInt4; subtype TSTR_MNT_Field is STM32_SVD.UInt3; subtype TSTR_HU_Field is STM32_SVD.UInt4; subtype TSTR_HT_Field is STM32_SVD.UInt2; subtype TSTR_PM_Field is STM32_SVD.Bit; -- time stamp time register type TSTR_Register is record -- Read-only. Second units in BCD format SU : TSTR_SU_Field; -- Read-only. Second tens in BCD format ST : TSTR_ST_Field; -- unspecified Reserved_7_7 : STM32_SVD.Bit; -- Read-only. Minute units in BCD format MNU : TSTR_MNU_Field; -- Read-only. Minute tens in BCD format MNT : TSTR_MNT_Field; -- unspecified Reserved_15_15 : STM32_SVD.Bit; -- Read-only. Hour units in BCD format HU : TSTR_HU_Field; -- Read-only. Hour tens in BCD format HT : TSTR_HT_Field; -- Read-only. AM/PM notation PM : TSTR_PM_Field; -- unspecified Reserved_23_31 : STM32_SVD.UInt9; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSTR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype TSDR_DU_Field is STM32_SVD.UInt4; subtype TSDR_DT_Field is STM32_SVD.UInt2; subtype TSDR_MU_Field is STM32_SVD.UInt4; subtype TSDR_MT_Field is STM32_SVD.Bit; subtype TSDR_WDU_Field is STM32_SVD.UInt3; -- time stamp date register type TSDR_Register is record -- Read-only. Date units in BCD format DU : TSDR_DU_Field; -- Read-only. Date tens in BCD format DT : TSDR_DT_Field; -- unspecified Reserved_6_7 : STM32_SVD.UInt2; -- Read-only. Month units in BCD format MU : TSDR_MU_Field; -- Read-only. Month tens in BCD format MT : TSDR_MT_Field; -- Read-only. Week day units WDU : TSDR_WDU_Field; -- unspecified Reserved_16_31 : STM32_SVD.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSDR_Register use record DU at 0 range 0 .. 3; DT at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; MU at 0 range 8 .. 11; MT at 0 range 12 .. 12; WDU at 0 range 13 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype TSSSR_SS_Field is STM32_SVD.UInt16; -- timestamp sub second register type TSSSR_Register is record -- Read-only. Sub second value SS : TSSSR_SS_Field; -- unspecified Reserved_16_31 : STM32_SVD.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSSSR_Register use record SS at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CALR_CALM_Field is STM32_SVD.UInt9; subtype CALR_CALW16_Field is STM32_SVD.Bit; subtype CALR_CALW8_Field is STM32_SVD.Bit; subtype CALR_CALP_Field is STM32_SVD.Bit; -- calibration register type CALR_Register is record -- Calibration minus CALM : CALR_CALM_Field := 16#0#; -- unspecified Reserved_9_12 : STM32_SVD.UInt4 := 16#0#; -- Use a 16-second calibration cycle period CALW16 : CALR_CALW16_Field := 16#0#; -- Use an 8-second calibration cycle period CALW8 : CALR_CALW8_Field := 16#0#; -- Increase frequency of RTC by 488.5 ppm CALP : CALR_CALP_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CALR_Register use record CALM at 0 range 0 .. 8; Reserved_9_12 at 0 range 9 .. 12; CALW16 at 0 range 13 .. 13; CALW8 at 0 range 14 .. 14; CALP at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype TAFCR_TAMP1E_Field is STM32_SVD.Bit; subtype TAFCR_TAMP1TRG_Field is STM32_SVD.Bit; subtype TAFCR_TAMPIE_Field is STM32_SVD.Bit; subtype TAFCR_TAMP2E_Field is STM32_SVD.Bit; subtype TAFCR_TAMP2TRG_Field is STM32_SVD.Bit; subtype TAFCR_TAMP3E_Field is STM32_SVD.Bit; subtype TAFCR_TAMP3TRG_Field is STM32_SVD.Bit; subtype TAFCR_TAMPTS_Field is STM32_SVD.Bit; subtype TAFCR_TAMPFREQ_Field is STM32_SVD.UInt3; subtype TAFCR_TAMPFLT_Field is STM32_SVD.UInt2; subtype TAFCR_TAMPPRCH_Field is STM32_SVD.UInt2; subtype TAFCR_TAMPPUDIS_Field is STM32_SVD.Bit; subtype TAFCR_PC13VALUE_Field is STM32_SVD.Bit; subtype TAFCR_PC13MODE_Field is STM32_SVD.Bit; subtype TAFCR_PC14VALUE_Field is STM32_SVD.Bit; subtype TAFCR_PC14MODE_Field is STM32_SVD.Bit; subtype TAFCR_PC15VALUE_Field is STM32_SVD.Bit; subtype TAFCR_PC15MODE_Field is STM32_SVD.Bit; -- tamper and alternate function configuration register type TAFCR_Register is record -- Tamper 1 detection enable TAMP1E : TAFCR_TAMP1E_Field := 16#0#; -- Active level for tamper 1 TAMP1TRG : TAFCR_TAMP1TRG_Field := 16#0#; -- Tamper interrupt enable TAMPIE : TAFCR_TAMPIE_Field := 16#0#; -- Tamper 2 detection enable TAMP2E : TAFCR_TAMP2E_Field := 16#0#; -- Active level for tamper 2 TAMP2TRG : TAFCR_TAMP2TRG_Field := 16#0#; -- Tamper 3 detection enable TAMP3E : TAFCR_TAMP3E_Field := 16#0#; -- Active level for tamper 3 TAMP3TRG : TAFCR_TAMP3TRG_Field := 16#0#; -- Activate timestamp on tamper detection event TAMPTS : TAFCR_TAMPTS_Field := 16#0#; -- Tamper sampling frequency TAMPFREQ : TAFCR_TAMPFREQ_Field := 16#0#; -- Tamper filter count TAMPFLT : TAFCR_TAMPFLT_Field := 16#0#; -- Tamper precharge duration TAMPPRCH : TAFCR_TAMPPRCH_Field := 16#0#; -- TAMPER pull-up disable TAMPPUDIS : TAFCR_TAMPPUDIS_Field := 16#0#; -- unspecified Reserved_16_17 : STM32_SVD.UInt2 := 16#0#; -- PC13 value PC13VALUE : TAFCR_PC13VALUE_Field := 16#0#; -- PC13 mode PC13MODE : TAFCR_PC13MODE_Field := 16#0#; -- PC14 value PC14VALUE : TAFCR_PC14VALUE_Field := 16#0#; -- PC 14 mode PC14MODE : TAFCR_PC14MODE_Field := 16#0#; -- PC15 value PC15VALUE : TAFCR_PC15VALUE_Field := 16#0#; -- PC15 mode PC15MODE : TAFCR_PC15MODE_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TAFCR_Register use record TAMP1E at 0 range 0 .. 0; TAMP1TRG at 0 range 1 .. 1; TAMPIE at 0 range 2 .. 2; TAMP2E at 0 range 3 .. 3; TAMP2TRG at 0 range 4 .. 4; TAMP3E at 0 range 5 .. 5; TAMP3TRG at 0 range 6 .. 6; TAMPTS at 0 range 7 .. 7; TAMPFREQ at 0 range 8 .. 10; TAMPFLT at 0 range 11 .. 12; TAMPPRCH at 0 range 13 .. 14; TAMPPUDIS at 0 range 15 .. 15; Reserved_16_17 at 0 range 16 .. 17; PC13VALUE at 0 range 18 .. 18; PC13MODE at 0 range 19 .. 19; PC14VALUE at 0 range 20 .. 20; PC14MODE at 0 range 21 .. 21; PC15VALUE at 0 range 22 .. 22; PC15MODE at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype ALRMASSR_SS_Field is STM32_SVD.UInt15; subtype ALRMASSR_MASKSS_Field is STM32_SVD.UInt4; -- alarm A sub second register type ALRMASSR_Register is record -- Sub seconds value SS : ALRMASSR_SS_Field := 16#0#; -- unspecified Reserved_15_23 : STM32_SVD.UInt9 := 16#0#; -- Mask the most-significant bits starting at this bit MASKSS : ALRMASSR_MASKSS_Field := 16#0#; -- unspecified Reserved_28_31 : STM32_SVD.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMASSR_Register use record SS at 0 range 0 .. 14; Reserved_15_23 at 0 range 15 .. 23; MASKSS at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype ALRMBSSR_SS_Field is STM32_SVD.UInt15; subtype ALRMBSSR_MASKSS_Field is STM32_SVD.UInt4; -- alarm B sub second register type ALRMBSSR_Register is record -- Sub seconds value SS : ALRMBSSR_SS_Field := 16#0#; -- unspecified Reserved_15_23 : STM32_SVD.UInt9 := 16#0#; -- Mask the most-significant bits starting at this bit MASKSS : ALRMBSSR_MASKSS_Field := 16#0#; -- unspecified Reserved_28_31 : STM32_SVD.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMBSSR_Register use record SS at 0 range 0 .. 14; Reserved_15_23 at 0 range 15 .. 23; MASKSS at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Real-time clock type RTC_Peripheral is record -- time register TR : aliased TR_Register; -- date register DR : aliased DR_Register; -- control register CR : aliased CR_Register; -- initialization and status register ISR : aliased ISR_Register; -- prescaler register PRER : aliased PRER_Register; -- wakeup timer register WUTR : aliased WUTR_Register; -- alarm A register ALRMAR : aliased ALRMAR_Register; -- alarm B register ALRMBR : aliased ALRMBR_Register; -- write protection register WPR : aliased WPR_Register; -- sub second register SSR : aliased SSR_Register; -- shift control register SHIFTR : aliased SHIFTR_Register; -- time stamp time register TSTR : aliased TSTR_Register; -- time stamp date register TSDR : aliased TSDR_Register; -- timestamp sub second register TSSSR : aliased TSSSR_Register; -- calibration register CALR : aliased CALR_Register; -- tamper and alternate function configuration register TAFCR : aliased TAFCR_Register; -- alarm A sub second register ALRMASSR : aliased ALRMASSR_Register; -- alarm B sub second register ALRMBSSR : aliased ALRMBSSR_Register; -- backup register BKP0R : aliased STM32_SVD.UInt32; -- backup register BKP1R : aliased STM32_SVD.UInt32; -- backup register BKP2R : aliased STM32_SVD.UInt32; -- backup register BKP3R : aliased STM32_SVD.UInt32; -- backup register BKP4R : aliased STM32_SVD.UInt32; -- backup register BKP5R : aliased STM32_SVD.UInt32; -- backup register BKP6R : aliased STM32_SVD.UInt32; -- backup register BKP7R : aliased STM32_SVD.UInt32; -- backup register BKP8R : aliased STM32_SVD.UInt32; -- backup register BKP9R : aliased STM32_SVD.UInt32; -- backup register BKP10R : aliased STM32_SVD.UInt32; -- backup register BKP11R : aliased STM32_SVD.UInt32; -- backup register BKP12R : aliased STM32_SVD.UInt32; -- backup register BKP13R : aliased STM32_SVD.UInt32; -- backup register BKP14R : aliased STM32_SVD.UInt32; -- backup register BKP15R : aliased STM32_SVD.UInt32; -- backup register BKP16R : aliased STM32_SVD.UInt32; -- backup register BKP17R : aliased STM32_SVD.UInt32; -- backup register BKP18R : aliased STM32_SVD.UInt32; -- backup register BKP19R : aliased STM32_SVD.UInt32; -- backup register BKP20R : aliased STM32_SVD.UInt32; -- backup register BKP21R : aliased STM32_SVD.UInt32; -- backup register BKP22R : aliased STM32_SVD.UInt32; -- backup register BKP23R : aliased STM32_SVD.UInt32; -- backup register BKP24R : aliased STM32_SVD.UInt32; -- backup register BKP25R : aliased STM32_SVD.UInt32; -- backup register BKP26R : aliased STM32_SVD.UInt32; -- backup register BKP27R : aliased STM32_SVD.UInt32; -- backup register BKP28R : aliased STM32_SVD.UInt32; -- backup register BKP29R : aliased STM32_SVD.UInt32; -- backup register BKP30R : aliased STM32_SVD.UInt32; -- backup register BKP31R : aliased STM32_SVD.UInt32; end record with Volatile; for RTC_Peripheral use record TR at 16#0# range 0 .. 31; DR at 16#4# range 0 .. 31; CR at 16#8# range 0 .. 31; ISR at 16#C# range 0 .. 31; PRER at 16#10# range 0 .. 31; WUTR at 16#14# range 0 .. 31; ALRMAR at 16#1C# range 0 .. 31; ALRMBR at 16#20# range 0 .. 31; WPR at 16#24# range 0 .. 31; SSR at 16#28# range 0 .. 31; SHIFTR at 16#2C# range 0 .. 31; TSTR at 16#30# range 0 .. 31; TSDR at 16#34# range 0 .. 31; TSSSR at 16#38# range 0 .. 31; CALR at 16#3C# range 0 .. 31; TAFCR at 16#40# range 0 .. 31; ALRMASSR at 16#44# range 0 .. 31; ALRMBSSR at 16#48# range 0 .. 31; BKP0R at 16#50# range 0 .. 31; BKP1R at 16#54# range 0 .. 31; BKP2R at 16#58# range 0 .. 31; BKP3R at 16#5C# range 0 .. 31; BKP4R at 16#60# range 0 .. 31; BKP5R at 16#64# range 0 .. 31; BKP6R at 16#68# range 0 .. 31; BKP7R at 16#6C# range 0 .. 31; BKP8R at 16#70# range 0 .. 31; BKP9R at 16#74# range 0 .. 31; BKP10R at 16#78# range 0 .. 31; BKP11R at 16#7C# range 0 .. 31; BKP12R at 16#80# range 0 .. 31; BKP13R at 16#84# range 0 .. 31; BKP14R at 16#88# range 0 .. 31; BKP15R at 16#8C# range 0 .. 31; BKP16R at 16#90# range 0 .. 31; BKP17R at 16#94# range 0 .. 31; BKP18R at 16#98# range 0 .. 31; BKP19R at 16#9C# range 0 .. 31; BKP20R at 16#A0# range 0 .. 31; BKP21R at 16#A4# range 0 .. 31; BKP22R at 16#A8# range 0 .. 31; BKP23R at 16#AC# range 0 .. 31; BKP24R at 16#B0# range 0 .. 31; BKP25R at 16#B4# range 0 .. 31; BKP26R at 16#B8# range 0 .. 31; BKP27R at 16#BC# range 0 .. 31; BKP28R at 16#C0# range 0 .. 31; BKP29R at 16#C4# range 0 .. 31; BKP30R at 16#C8# range 0 .. 31; BKP31R at 16#CC# range 0 .. 31; end record; -- Real-time clock RTC_Periph : aliased RTC_Peripheral with Import, Address => System'To_Address (16#40002800#); end STM32_SVD.RTC; ",12115,True,2921.6833087258246,median "= User Guide Apache Roller Weblogger :toc: :sectnums: :imagesdir: ./images == Overview This document is a user guide to the Apache Roller Weblogger, the Java-based and open source weblog server that is produced by the Apache Roller project of the Apache Software Foundation. There are separate guides available on other topics; a Template Guide for those who wish to customize the layout and design of their weblog pages and an Installation Guide for those installing the Roller software on a web server. === Copyright and trademark information The contents of this document are subject to the terms of the Apache Software License. All trademarks within this document belong to legitimate owners. === Feedback Please direct any comments or suggestions about this document to: dev@roller.apache.org == Introduction This user guide describes how to use the Apache Roller Weblogger or Roller for short, a web application that can support a single user weblog, thousands of weblogs and/or group weblogs. You’ll learn how to register as a new user. You’ll learn how to create one or more weblogs for yourself or a group of your friends. You’ll learn how to create, edit and post weblog entries. We will also cover more advanced topics such as adjusting your weblog’s settings, how to customize your blogroller, how to manage weblog pings and more. First, let’s get some terminology out of the way because there’s a lot of jargon in weblogging. Here’s a list of some of the terms we use in this manual without a whole lot of background. * *Weblog*: A set of web pages and RSS/Atom feeds that display weblog entries written by one or more authors, uploaded images, bookmarks and comments posted by visitors. Weblog entries are displayed on the main page of the weblog and in the weblog’s feeds in reverse chronological order. * *Weblog entry*. A single weblog entry with a title, publication timestamp, summary, content and some settings that indicate if and when comments are allowed. * *Comment*. A comment posted by a visitor to a weblog and regarding one specific weblog post. A comment has an email address, a publication timestamp and some content. * *Trackback*. A comment posted by a remote weblog regarding one specific weblog post. Trackbacks are stored as comments by Roller. * *Templates*. Each Roller weblog is defined by a set of HTML and CSS templates that provide the layout and styles for the weblog. Normally templates are authored using Velocity template language, but other languages are possible via plugins (i.e. Groovy Server Pages, JRuby, etc.) * *Feed*. A feed is an XML representation of the most recent entries, comments or other data. Folks can subscribe to your feed to be alerted of new weblog entries and comments posted. Roller supports both RSS and Atom formats for feeds. * *Feed reader*. Software that makes it easy to subscribe to and read feeds, e.g. Google Reader, Net News Wire, Feed Demon, etc. * *Blog client*. Software that makes it easy to post to your weblog, e.g. Ecto and Mars Edit. With that out of the way, let’s get started blogging with Roller. == Getting started with Roller Getting started with Roller means different things to different people. If you are using an existing Roller server, then getting started means registering a new user and creating or joining a weblog. If that’s the case for you, skip ahead to section 3.2. If you just finished setting up your own Roller installation on your own web server, then getting started means a little bit more. You’ve got a little post installation work to do. === Getting started with a new Roller installation Once you’ve got Roller up and running you will see a screen like the one below, which explains exactly what you’ve got to do to get started with Roller. First, create a new user so you can login. Second, login and create a weblog for yourself or one to server as the front page of the site or both. Third, designate which weblog is the front page weblog. image::user-guide-1-welcome.png[] **Creating the first user. **Your first step is to create a new user. Remember, the first user you create will be given administrative privileges. You might want to use the username ""admin"" or something similar. Later, you can login as the admin user when you need to change site-wide settings. If you wish, you can grant other users admin privileges so they can help out with admin duties. Let’s take a look at the user registration page. You can see the new user registration form in the next section. **Create the first weblog(s). **Next you should create at least one weblog. See section 3.2 below for some more information the create weblog page. If you are running a personal blog site, then you might want your weblog to serve as the front page of your site. In that case, create a weblog, use a normal weblog theme (i.e. not the Roller Homepage theme) and assign your weblog as the front page weblog of the site. If you are running a community weblog site with multiple weblogs, then you will probably want to create a weblog to serve as the front page of the site. Create a new weblog, name it ""main"" or ""community"" or something suitable because its name will appear in URLs. And we recommend that you use the Roller Homepage theme because it is specially designed to serve as a weblog community front page, aggregating all of the site’s weblogs together but having no content of its own. **Designate a front page weblog. **Once you’ve created a front page weblog, whether it be a personal weblog or a community aggregator, you need to tell Roller. So, select your front page weblog and, if you are running a community site then set the _Enable aggregated site-wide frontpage_ checkbox before you click Save. If you’ve read this far, you’ve probably created your own user and weblog and if so you can skip the next section. === Creating a new user and weblog To create a new user use the Register link, which can be found in the top right of the Roller login page. That link will take you to the New User Registration page shown below. image::user-guide-2-registration.png[] The New User Registration form is pretty self-explanatory, but keep in mind that your username cannot be changed; it is your unique identifier in the system. But that’s OK because your screen name is the name that will be displayed on your weblog and in your feeds and you _can_ change it later if you wish. Instead of username and password, the Roller administrator may provide (or require) OpenID (http://openid.net/[http://openid.net]) authentication. With OpenID you will not provide a password (as you will be logging into another system to authenticate) but just your OpenID account name, whose format will vary based on the OpenID provider. For example, using Google+ as your OpenID provider will result in an account name similar to https://profiles.google.com/<numeric-ID >, where the numeric identifier can be determined simply by Googling your name along with ""google plus"". (Note the OpenID string does _not_ use the plus.google.com domain returned by this query.) **Picking your language and timezone. **You can set your language of choice and timezone too, but these values don’t do much in Roller. The locale and timezone of your weblog are really what matter. The values you set here will be used as your defaults when you create your weblog. **Creating a weblog . **Once you’ve created a user, then log in and you’ll see the Roller Main Menu page and a greeting that reads: You’ve got a user account, but no weblog. Would you like to _create one_? Follow that link to create your first weblog. You’ll see the form below. image::user-guide-3-webblog.png[] The form is designed to be self-explanatory. Note that you can change everything later, except for the weblog handle, which is the unique identifier for your weblog. Now that you’ve got a user and a weblog, let’s discuss how to get around in the Roller interface. === Getting around in Roller Once you’ve logged into Roller’s editor pages you should be able to find your way around using Roller’s tabbed menu. To provide a little extra assistance, Roller displays a status bar at the top of each editor page. For example, the status bar below indicates that you are logged in as user 'admin' and you are not editing a weblog. You can go directly to the front page of the site by clicking the first link on the right (it might not be labelled Front Page on your site), to the main menu with the second link and you can log out entirely by using the Logout. image::user-guide-4-statusbar.png[] For example, the status bar below indicates that you are logged in as user 'admin' and you are editing a weblog with the handle 'adminblog'. image::user-guide-5-statusbar-webblog.png[] If you are not logged into Roller then you can either access the login link directly or use a Login link from one of the weblogs on the site. The login link is of this form: _http://hostname/roller-ui/login-redirect.rol_ Or this form if Roller is installed under its own context: _http://hostname/roller/roller-ui/login-redirect.rol_ You probably won’t need to cut-and-paste that link because most weblogs display an author menu like so: image::user-guide-6-navigation.png[] Now that we’ve covered the basics of registering a new user, creating a new weblog and finding your way around let’s start blogging. == Creating and editing your weblog First, you log in to Roller. What happens next depends on the number of weblogs that you have. If you have one weblog, you’ll be taken directly to the *New Entry* page for that weblog. If you have more than one weblog or none at all, then you’ll be taken to the *Main Menu* page, shown below, so you can pick which weblog to edit and/or create new weblogs. image::user-guide-7-main-menu.png[] The main menu page lists all of your weblogs and for each, shows you links to its New Entry, Entries, Comments, Theme and Settings pages. You can also create a new weblog, edit your user profile. If you are logged in as a Global Administrator, you will also see a Server Admin link in the actions side-bar. And if you have Roller’s Planet aggregator enabled, then you will also see a Planet Admin link there as well. === Creating and editing a weblog entry Use the *Create & Edit -> New Entry* page (also known as the Weblog editor page) to create, edit and publish weblog entries. Using this page, shown below in illustration 7, you can set entry title, category, content and summary. You can also set some advanced settings by expanding the _Plugins To Apply_ and _Advanced Settings_ controls at the bottom of the page. Let’s review those fields, buttons and settings. image::user-guide-8-editor.png[] ==== Weblog editor fields Let’s discuss each of the fields on the New Entry page, so you know how to use them. * *Title* – Each weblog entry must have a title. Be careful when you pick your title, it will be used in the permalink (URL) for your weblog entry (up to the first five words of the blog title, separated by hyphens). For best results, _do_ use titles that are short and to-the-point. __Don’t __include any HTML in your titles, just plain text – if you want your titles to be bold, then customize your templates instead of embedding HTML in your titles. + To generate a permalink different from the actual blog title, first type in the desired permalink, then hit Save As Draft which will create the permalink. Then change the blog title to whatever desired for the blog entry prior to publishing it—the permalink won’t change. * *Status* – This read-only field tells you about the current state of the weblog entry that you are editing. There are three possible status settings: * _Not Saved_ – the entry has never been saved * _Draft_ – the entry is saved as a draft and is not yet visible to your weblog’s readers * _Published_ – the entry has been published and is visible to your weblog’s readers * *Permalink* – this read-only field is the permalink link to your weblog entry. It is set the first time that you save an entry, based on the title at the time you save (see Title section above), and it cannot be changed later. As a workaround for getting a new permalink, the text of a blog entry can be copied to a new blog entry with the desired permalink and the published date set back to that of the original blog entry (Advanced settings). Once the new blog entry is published, then just delete the old blog entry with the undesired URL. However, be cautious about changing a permalink in this manner because all external links to original blog entry will be broken as a result. * *Category* – You can pick one category for your weblog entry. Categories are for folks who want to organize their weblog entries by subject. You can add and remove categories via the Categories page. * *Tags* – (optional) In addition to assigning each of your weblog entries to a category you can also tag them. You can assign a list of tags to each entry. You can use any tag name you want. Separate your tags with spaces. Currently, the only way to do multi-word tags is to use an underbar, for example to tag something with ""apache roller"" you would use the tag apache_roller. As you type, Roller may suggest tags that you’ve used before. * *Content* – This is the main body of your weblog entry, in HTML format. We try to make that easy by providing two ways to edit the content. Via the Settings page, you can pick either of these: * *Rich Text Editor (Xinha)* – a rich-text editor that’s designed to make editing HTML as easy as using MS Word or Open Office. * *Text Editor* – a plain-text editor that you can use to edit the raw HTML markup of your weblog entries. Don’t use this unless you know HTML. * *Summary* – (optional) If you wish, you can enter a short summary of your weblog post. If you do so, then the short summary will be displayed on the main page of your weblog and your readers will have to click a Read More link to get to the full-content. Some bloggers like to do this when they have very long post and they don’t want that long post to dominate the main page of their weblog. ==== Weblog editor buttons Here’s a guide to the buttons that appear on the Weblog editor page. * *Post to weblog* – Using this button will publish your weblog entry and make it visible to the world. Make sure you’re happy with your post before you publish because once something is published on the web, and grabbed by the blog aggregators and search engines, _there’s really no way to un-publish_ it. * *Submit for review* – if you’re just a limited blogger, you won’t see the Post to weblog button because you cannot post to the web. Instead, you’ll see a Submit for review button which you can use to send your entry to the author/admin of the blog that you are working in. If they like the post, they can publish it – or they can return it to you for further edits. * *Save as draft* – this will save your weblog post for later editing, but will _not_ publish it to the web. When you’re working on a new weblog entry, use Save as draft often so you won’t lose your post in the event of internet connection loss or session time-out. * *Delete entry* – use this to delete the current weblog entry, you’ll be asked to confirm. * *Full preview* – You won’t see this button until you’ve saved your entry as a draft. It allows you to view, in a separate window, a preview of your entry, displayed using the layout and style of your blog. ==== Weblog editor plugin settings If you expand the _Plugins to Apply_ control, you’ll see a set of check-boxes, one for each Weblog Entry Plugin that is available. Check the ones that you’d like to apply to your current weblog entry. If you have a favorite plugin, one that you want to use on every entry, then you can set it as a default on your weblog’s Settings page. image::user-guide-plugin.png[] ==== Weblog editor advanced settings If you expand the _Advanced Settings_ control, you’ll see what’s below. image::user-guide-settings.png[] All of these are optional settings. * *Pub Time* – if you’d like to set the publication time of your weblog entry to a specific time, possibly one in the future, you can do so here. * *Allow comments for* – this setting allows you to turn comments on/off for your weblog entry and to limit the number of days that comments are allowed. * *Text reads left-to-right* – this settings allows you to set the reads left-to-right flag for a weblog entry. Currently, none of the stock Roller templates respect this setting. * Pinned to main – only Global Administrators will see this setting. It’s a way to indicate that a post is a __special announcement __that should be pinned to the top of the front-page of a weblog site. The front-page theme respects this setting. * *Enclosure URL*: if you’d like to include a audio, video or image file as a p__odcast__ in your weblog’s RSS feed, then enter the URL of that file here. === Finding and editing weblog entries All of your weblog entries are saved in a database. Once your entries scroll off the front page or off the recent entries list of the weblog editor page, they are still available via next and previous links displayed on your weblog and via the weblog calendar that is included in most weblog themes. You can also access your entries via the Edit Entries page, which allows you to search entries via keyword, category, tags, date and status. image::user-guide-9-entries.png[] === Managing categories Each weblog can define its own unique list of categories to be used for categorizing weblog entries, using the Categories page shown below. When you or another author of your weblog creates a new entry you _must_ choose one of the categories you have defined. image::user-guide-10-categories.png[] You can use the Categories page to add new categories and to edit your existing ones. You can change category names if you wish. And you can also delete categories and if a category is in use you will be asked to re-categorize the entries in that category. You can also define icons for each category, but support for icon images has not been coded in most Roller themes, requiring you to do template customization if you wish to display them. === Managing your weblog’s blogroll Roller makes it easy to maintain a _blogroll_, that is, a list of your favorite weblogs and web sites that is displayed in the sidebar of your weblog. Individual blogroll items are known as _bookmarks_. Use the *Create & Edit:Blogroll* page to add, edit and delete bookmarks and bookmark folders in your blogroll. image::user-guide-11-blogroll.png[] === Uploading images and other files to your weblog If you’d like to upload images or other files for use in your weblog, go to your weblog’s *Create & Edit -> Media Files* page. From there you can upload files, browse and search files. You can also manage your files, organize them into directories and post them to your weblog. image::user-guide-12-media.png[] You can see the Media File View page above. Below we’ll discuss all of the things you can do with Media Files via the Media File View page and the new Media File browser that we’ve added to the Weblog Editor. ==== How to upload files To upload files you follow the *Add Media File* link in the top right of the page. You will see the Media File Add page, which is pictured below. image::user-guide-13-add-media.png[] You can upload up to five files at a time and you can enter information about the images including title, description, copyright statement and tags. You can pick which directory should receive the uploaded images. You can also decide whether or not you want your images to be included in the Gallery, which means that they will be made available in the Media File Feed for your blog. After your file upload completes, Roller will show you the *Upload Complete* page (below) with the files that you uploaded and will offer to include them in a new weblog post for you. You can choose any or all of the images, or you can skip this step and return to the Media File View. image::user-guide-14-upload-complete.png[] ==== How to edit and update files From the Media File View page, you can edit any Media File simply by clicking on it. When you click you will be shown the Media File Edit page (below). From this page, you can edit the same information that you entered when you uploaded the file. You can also upload a new version of the file. The file will maintain the same URL as before the update, so no worries about broken links. If the file is an image, a new thumbnail will be generated for you and image size information will be updated. image::user-guide-15-edit-media.png[] ==== How to use Media File Directories You can use directories to organize your Media Files. You can move files around and not worry about breaking any links because directory and file names are not part of URLs. To create a new directory, enter a new directory name in the new directory control, and click the create button. image::user-guide-media-directory.png[] To navigate into a directory in the Media File View page, simply click on the directory. ==== How to delete Media Files To delete Media Files, go to the *Media File View* page, select the checkboxes of the files you wish to delete and then click the Delete button. You will have to confirm the delete before it executes. ==== How to delete Media File Directories To delete Media File Directories you must first empty them out. You can only delete directories that are empty. ==== How to post media files to your weblog We explained above how to post images during the upload process. From the Blog entry edit page, click on the ""Add Media File"" link located above and to the right of the Content field. Roller will insert the media file at the cursor location in the content field. If there’s a problem with the insertion location, hit Ctrl-Z to undo the action and try again. ==== How to post a podcast to your weblog Upon uploading a non-image media file, such as a podcast, Roller provides you an option to create a new blog entry with that media file (podcast). If chosen, Roller will include the media file in the post content and in the Enclosure URL field in the Advanced Settings section of the Blog Edit Entry page. The Enclosure URL field is used just for your blog’s RSS and Atom feeds, it will include the podcast as a feed enclosure (http://en.wikipedia.org/wiki/RSS_enclosure) to make it easy for podcast readers to fetch it. Alternatively, you can select an podcast from the Add Media File link referenced in the previous section, which will add its URL to the post content, and then copy that URL to the Enclosure URL field in the Advanced Settings section if you wish to add it to your blog’s RSS and/or Atom feeds. === Podcasting with Roller Roller includes support for _podcasting_, a way to distribute files through your weblog’s newsfeed. Typically, folks use podcasting to distribute audio files, but the technique can be used to distribute any type of file. Specialized podcast client software downloads the audio files that are referenced in your newsfeed and copies them to an music player, such as an MP3 player. This section assumes that you want to upload your podcasts to some other server, one with lots of space and bandwidth, and not to Roller. If you want to upload your podcasts to Roller, then see *Section 4.5.7* for an explanation of posting a Media File to your weblog as a podcast. ==== *How to create a podcast feed with Roller* In Roller a Podcast is like an attachment to a weblog entry. Here are the steps involved in Podcasting with Roller: * Record an interesting Podcast (that’s the hard part, by the way) and save your Podcast in MP3 format or whatever format you prefer. * Upload your Podcast to a web server somewhere and take note of your Podcast’s URL. For example, if you were to upload a file to Roller, then the URL might look something like this: _http://hostname/roller/yourname/resource/mycast.mp3_ * Create a new Roller weblog entry announcing your new Podcast. You might want to provide a link to it so that those without a Podcast client can click to download it directly. For example: Hey now! I just created my first Podcast you can download it here: mycast.mp3 * And the most important step: in the lower-half of the weblog editor page, you’ll see an expandable control labelled _Advanced Settings_. Click on that to expand the control and paste in the URL of your podcast. * Once your blog post is ready, save it as a draft or publish it. Once you’ve done that you’ll see that the Advanced Settings control has picked up the content-type and file-size of your podcast. If not, then Roller could not access your podcast due to network problems or perhaps a bad URL. Make sure the URL is correct and save again. If your podcast is OK, you’ll see something like this: image::user-guide-podcast.png[] * Roller will add the podcast to your RSS newsfeed as an __. You can check this by looking at your RSS newsfeed and any podcast software that is subscribed to your feed will pick it up automatically. === Using a weblog client with Roller Using a nice weblog client like Ecto or MarsEdit can make it easier for you to post to your Roller weblog. You can also post to your weblog remotely from services like Flickr.com and del.icio.us. This is possible because Roller supports a standard publishing protocols such as the MetaWeblog API and the Atom Publishing Protocol. Here’s how to set up a weblog client to post to Roller. Configuring a weblog client for use with Roller First, make sure to enable weblog client API support in your weblog via your weblog’s Weblog Settings page. image::user-guide-17-api.png[] Next, start your blogging client, find the preferences or account setup dialog. You’ll need to set the following parameters: * *Username*: your Roller username * *Password*: your Roller password * *BlogID*: the handle of your Roller weblog * *URL*: the URL of Roller’s web services end-point Note that you may not need to enter your BlogID because some blog clients will login to Roller and then present you with a list of the weblogs that are available to your user. *A blogs.sun.com example*. For example, if you have an account on blogs.sun.com, your username is fred and your blog’s handle is fredsblog (i.e. your weblog’s URL is _http://blogs.sun.com/fredsblog_), then your parameters would be: * *Username*: fred * *Password*: (your password) * *BlogID*: fredsblog * *URL*: http://blogs.sun.com/roller-services/xmlrpc You may not need to enter your BlogID because some blog clients will login to Roller and then present you with a list of the weblogs that are available to your user. *A jroller.com example*. If you have an account on jroller.com, your username is fred and your blog’s handle is fredsblog (i.e. your weblog’s URL is _http://jroller.com/fredsblog_), then your parameters would be: * *Username*: fred * *Password*: (your password) * *BlogID*: fredsblog * *URL*: http://jroller.com/roller-services/xmlrpc == Working with comments and trackbacks Roller supports weblog comments and _trackbacks_, which provide a way for other bloggers to add comments to your blog remotely. By default comments and trackbacks are enabled, but you can turn them off on your weblog’s Weblog Settings page of your weblog. Note that turning off comments will disable both comments and trackbacks. === Comment notification via email If you’re going to leave comments turn on then take the time to read them, to respond where appropriate and, when you receive spam or other forms of offensive comments, delete them from your weblog. You can’t respond to comments if you don’t know when you get one, so make sure you enable email notification of comments. You can do that on the Weblog Settings page. If you’ve got email turned on then you’ll receive an email every time you get a new comment and the email will include the text of the comment, a link to the entry that was commented upon and a link to the comment management page, shown below, where you may choose to approve, mark as spam or even delete the new comment. === Comment management You can use the Comments page to manage your weblog comments. You can mark comments as spam or delete them entirely. You can search comments by keyword, date and status. If you’ve got comment moderation turned on, you will use the Comments page to approve new comments. image::user-guide-18-comments.png[] *A word about status* You can’t edit comments, but you can mark them as spam or dis-approve them. Someday, Roller may provide some spam filtering based on data collected from comments marked as spam but currently, marking as spam and dis-approving of a comment do the same thing – they prevent the comment from being displayed on your weblog. *How to get to the Comments page* There are a couple of ways to get to the Comments page. You can use Roller’s tabbed menu to go there and manage comment across your entire weblog. If you’ve got email notification of new comments turned on, the you might arrive at the Comments page via a link sent to you in your email. You can also manage comments for just one weblog. When you are editing a weblog entry with comments you’ll see a link in the top-right corner of the weblog editor page like the one below, which you can use to access the entry’s comments. === Comment moderation If you’d like to preview and approve comments before they are displayed on your weblog, then you’ll want to turn on _comment moderation_ via Weblog Settings page. When comment moderation is enabled, then each new comment will be marked as pending and unapproved and will not appear on your weblog. To check for new comments, go to the Comments page to check for and either approve or delete new comments. If you’ve got comment notification enabled, make sure you also enable comment notification so you’ll know when new comments arrive. To moderate comments, use the comment management page, described below. How to moderate comments * Review each new comment and decide if it is to be approved for display, marked as spam and hidden or deleted entirely. * Only comments that are marked as approved and are not spam will be displayed on your weblog. So set (or unset) the corresponding checkboxes for each comment, or leave them the way they are. * When you are done. Click the save changes button at the bottom of the page. You’ll see that comments that were pending are no longer pending and those that you marked for delete will be gone. === Global comment management If your user has global administration privileges, then you can manage comments across the entire Roller site, including every weblog. To do this, go to the *Server Administration:Comments* page and you’ll see a page that is almost identical to the weblog-specific comment management page. Limitations of global comment management You can use this page to mark as spam or delete any comment in the system, however you cannot change the approval status of comments through this interface. Approving comments for display is the duty and responsibility of the individual webloggers, so comment approval is only available in the context of a weblog. === *Preventing weblog spam* There are two forms of comment spam that can affect your weblog: ** _Comment spam_: spam that arrives via the comment form on your weblog. Sometimes spam comments are added by a human and sometimes by a computer program known as a _spambot._ ** _Trackback spam_: spam that arrives via trackbacks sent by a spambot. Fortunately, there are counter-measures for each type of spam. Here are Roller’s built in spam prevention measures: * _Pluggable comment authentication_. By default, Roller asks each commenter a simple math question to ensure that they are a person and not a spam robot. Your site administrator can turn this off or replace it with another form of authentication. * _Pluggable comment validation_. Roller includes five comment validators below. Your site administrator can adjust the settings for these validators and can enable/disable them as needed by overriding Roller’s configuration properties (see the Installation Guide for more information). ** Excess links validator will mark comments with more than three links as spam (default: on) ** Excess size validator marks any comment with more than 1000 characters as spam (default: on) ** Blacklist validator marks comments containing any of your site’s designated bad words as spam (default: on) ** Trackback verification validator will check incoming trackbacks to ensure that they link to you. ** Akismet validator allows you to use the Akismet.com spam prevention service. * _Comment throttling_. If your site is being abused by a spam robot your site administrator can set up throttling, which will watch for abusers and ban IP addresses that are posting too many comments too quickly. But nothing beats comment moderation Even if you’ve got all of those measures enabled you should still enable email notification of comments so that you are constantly aware of new comments on your weblog. None of the measures are 100% effective. If you are really concerned about displaying offensive content on your weblog even for a short time, then enable comment moderation on your weblog. Roller uses a _blacklist_, a lists of words which are used to check incoming comments, trackbacks and requestors for spam URLs. If the name, URL or content of a comment or trackback includes one of the blacklist words or matches one of the expressions then that comment or trackback is marked as spam and is not displayed on your weblog, unless you use the comment management page to unmark it. Actually, there are three levels of blacklist: ** Level 1 blacklist: This is the built-in blacklist, the one that comes with Roller. This can only be changed by somebody with root access to the Roller server itself. ** Level 2 blacklist: This is the site wide blacklist, which can only be edited by a global administrator via the Server Admin page. ** Level 3 blacklist: Weblog specific blacklist, which you control in the Weblog Settings page of your weblog. Incoming comments and trackbacks are checked against all three levels of blacklist. Incoming web page requests, however, are only checked against the levels 2 and 3 blacklist and will receive a 403 (forbidden) message if found. If you have a spam problem on your weblog and you’d like to add words to the blacklist, it’s probably better for you to ask your administrator to add the words to the level 2 blacklist for you. That way, every blogger on the site will benefit from the addition. If you must do it yourself, here’s how you do it: ** Go to the Weblog Settings page and scroll down to the blacklist fields ** Enter your spam words, one per line ** Lines that begin with a left parenthesis will be treated as regular expressions (see the Java API documentation for _javax.util.regex.Pattern_ for a guide to regular expressions). Don’t try to use a regular expression unless you really know what you’re doing. === Sending trackbacks If you are writing about something you read on another weblog, you want to let the author and readers of that weblog know that you are doing so, and that other weblog is trackback enabled, then you should send that weblog a trackback ping. Here’s a story that illustrates how trackback works: * You read an interesting blog entry on Otto’s blog. You notice that Otto’s blog entry has a trackback URL, so instead of leaving a comment on Otto’s blog you decide to comment by writing a blog entry in your own blog. You copy that trackback URL (using ALT-C, or right-click-copy, or whatever) cause you’ll need it later. * You go to your blog and write a new blog entry in response to Otto’s entry. Click the Post to Weblog button to publish your new entry. After you publish, scroll down on the New Entry page until you see the following text field and button: * Enter the trackback URL from Otto’s blog entry into the text field and click the Send Trackback button. Roller will respond by printing the response received from Otto’s blog server. If the trackback was successful, you should see something like this: * You should now see your trackback listed among the comments on Otto’s blog entry. == Choosing your weblog theme A weblog theme is a set of templates, style-sheets and image that determine how your weblog will be displayed. A theme can define both the layout and color-scheme of your weblog. You can pick from one of a number of predefined themes. Some themes will allow you to control design by using a stylesheet. Other themes require you to edit the templates that define the theme if you want to customize them. You can access Roller’s theme and template features for your weblog via the Design menu, shown below: image::user-guide-20-design-menu.png[] The Theme menu leads you to the theme chooser page, shown below. Using this page you can pick from one or more different themes for your weblog. If none of the themes are appealing to you, then speak to your site administrator about obtaining or developing some additional themes. The Roller Support project is one place where you can obtain additional themes (_http://roller.dev.java.net_, _not_ an Apache site). image::user-guide-design-theme.png[] For more information on customizing Roller themes refer to the Template Guide. == Managing your weblog preferences As a Roller user, you are free to customize the settings of your weblog as you wish. When you establish your Roller user account, you can choose one of the dozen or so stock themes for your website. Later, you can use the theme switcher to switch to a different theme. Or, if you know something about HTML and CSS you can customize the look-and-feel and layout of your weblog yourself by modifying the page templates that make up your site and by adding new pages. Best of all, you can do all of this through the web-based Roller Editor UI. === Weblog settings The *Preferences:Settings* page allows you to set the configuration parameters for your weblog. Here is an explanation of each of the settings on the weblog *Preferences:Settings* page: ==== *General settings* image::user-guide-settings.png[] * *Title* - The title of your weblog may include HTML, but the HTML will be stripped out in your RSS feed. You can access your title in a page template with the expression _#showWebsiteTitle()_ * *Tagline* – Short description or sub title of your weblog. May include HTML, but the HTML will be stripped out in your RSS feed. You can access your tagline in a page template with the expression _#showWebsiteDescription()_. * *Icon* - The image file name (ex: thumbnail.jpg) or image url (ex: http://yoursite/thumbnail.com) that shows on some of the default themes. You’ll need to upload the image via the *Create & Edit:File Uploads* tab first. * About your blog – A more detailed description of the blog or blog author(s) that shows on some of the default themes. * *Email address of weblog owner*: Enter the email address that you would like people to use to contact the person in charge of your blog; usually that’s you. To thwart spammers, your email address will be obfuscated when displayed on your blog. Please enter a valid address, otherwise Roller’s email features will not work. * *Weblog editor page to be used* - Choose a weblog editor page, some are rich-text editors: ** editor-text.jsp: Simple text editor, you must enter HTML ** editor-rte.jsp: Rich text editor (works in Firefox and IE but not Safari) * **Weblog is active: **un-check this box to indicate that your weblog is no longer active and should not appear in hot-blog and other weblog listing on the site. You might want to do this if you take a very long vacation or if you have decided to stop updating your weblog for some other reason. * *Number of entries to display on weblog*: Enter the maximum number of entries to be displayed on your weblog. ==== Internationalization Settings image::user-guide-internationalization.png[] * I publish my weblog in multiple languages: check this box if you blog in multiple languages and would like to specify a language locale for each of your weblog entries. * Show my weblog entries from all languages on my home page: check this box if you’d like your weblog’s main page to show your posts in all languages. If you don’t check it, then readers will only see weblog entries from your default locale. * Locale set the default locale for your weblog. * Timezone: the timezone to be used in your weblog. ==== Comments and default comment settings image::user-guide-comments.png[] * *Allow comments for your weblog?* – Check this box to allow visitors to leave comments on your weblog. * *Moderate comments* – Check this box to enable comment moderation (i.e. you must approve each comment before it is displayed). Note the next two options are visible only if the Roller Administrator has enabled email notifications for user blogs (See Section 9.2, Roller Administration): * *Email notification of comments?* – Check this box to receive an email notification of each new comments. * *Default from e-mail address for comments* – This will be used as the from address in comment emails sent by Roller. * *By default, allow comments for new entries* – Check this box to enable comments on your weblog. You can also control comments on each individual weblog entry. * Default time to allow comments for new entries – Choose the default amount of time to allow comments for new blog entries. This setting may also be overridden using the Comment Settings section of the New Entry page. * *Apply comment defaults to all existing entries? *- If you check this box, when you click the Save button the comment defaults you have set will be applied to all existing comments. ==== *Weblog client API* image::user-guide-17-api.png[] * *Enable Blogger API for your weblog* - Set to true to enable weblogging via the MetaWeblog API. This will allow you to use handy blogging clients like Ecto to post to your weblog. * *Category for posts received via Blogger API* - Choose the category for incoming posts made via the Blogger API. This only applies if you blogging client does not support categories ==== *Formatting* image::user-guide-formatting.png[] * **Default entry formatters: **this is the list of plug-ins to be enabled by default on a new weblog entry. ==== *Spam prevention* image::user-guide-spam.png[] * **Ignore incoming URLs that contain any of these words - **you can use this to filter out what commentors, trackbacks, and referrers (web page requestors) are accepted. See Section [link:#5.5.Preventing%20weblog%20spam%20%7Coutline[5.5]]for more information on spam prevention. ==== Web Analytics If you wish to use Web Analytics software tools such as Google Analytics (a fuller list of services is here: http://en.wikipedia.org/wiki/List_of_web_analytics_software) to track blog readers you can place your tracking code (usually a JavaScript snippet including the