Maximum concurrent sessions by default in Spring Boot - spring

I'm using Spring Boot version 1.5.13.
I can set the upper limit on concurrent sessions using the below code snippet in a configuration class -
http.sessionManagement().maximumSession($max_sesssions)
However, I want to know the default value of this limit.

The default is to allow any number of users. I navigated through the source code and found out the value is set to -1 for allowing any number of users by default.
Below is the snippet from ConcurrentSessionControlAuthenticationStrategy class -
/**
* Sets the <tt>maxSessions</tt> property. The default value is 1. Use -1 for
* unlimited sessions.
*
* #param maximumSessions the maximimum number of permitted sessions a user can have
* open simultaneously.
*/
public void setMaximumSessions(int maximumSessions) {
Assert.isTrue(
maximumSessions != 0,
"MaximumLogins must be either -1 to allow unlimited logins, or a positive integer to specify a maximum");
this.maximumSessions = maximumSessions;
}

According to Documentation, the default is to allow any number of
users.
.sessionManagement().maximumSessions(maximumSessions);
you can see the below details by Ctrl + Click on maximumSessions for eclips on windows.
SessionManagementConfigurer.java
/**
* Controls the maximum number of sessions for a user. The default is to allow any
* number of users.
* #param maximumSessions the maximum number of sessions for a user
* #return the {#link SessionManagementConfigurer} for further customizations
*/
public ConcurrencyControlConfigurer maximumSessions(int maximumSessions) {
this.maximumSessions = maximumSessions;
return new ConcurrencyControlConfigurer();
}

Related

Is there a way to route the emails (read via an imap idle adaptor) to different output channel based on the size of the email?

I have configured an Imap Idle adaptor which is listening to an email box, reading and parsing the email. The handling of these emails is done in a service activator class.
These emails are getting generated in bulk from an ERP system and have heavy attachments. Because of the heavy load, some emails are getting lost.
Is there a way in Spring integration to route these emails to different output channels based on the size and assign different handler classes to these output channels so that these emails can be processed in parallel and bulky emails don't block the processing?
Details of the configuration is in this ticket
The ImapIdleChannelAdapter produces a MimeMessage if you don't let it to convert the email into a simple content.
That MimeMessage has this method to check from your router:
/**
* Return the size of the content of this message in bytes.
* Return -1 if the size cannot be determined. <p>
*
* Note that this number may not be an exact measure of the
* content size and may or may not account for any transfer
* encoding of the content. <p>
*
* This implementation returns the size of the <code>content</code>
* array (if not null), or, if <code>contentStream</code> is not
* null, and the <code>available</code> method returns a positive
* number, it returns that number as the size. Otherwise, it returns
* -1.
*
* #return size of content in bytes
* #exception MessagingException for failures
*/
#Override
public int getSize() throws MessagingException {
See router for more info:
https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#messaging-routing-chapter
https://docs.spring.io/spring-integration/docs/current/reference/html/dsl.html#java-dsl-routers

How do I format OpenApi in swagger-php so that the swagger-ui shows a form instead of an array?

I'm on a Laravel build, and updating notations for all my API controller methods from #SWG to #OA. When I hit 'try it out' in the swagger-ui on a create method, I'm able to get it to show (and accept) an editable array of parameters and values (the latter being the examples I coded in), but I'd much rather get a form of the given parameters instead, to be sent in the body, not the query. I was able to do it in the older version by adding parameters and setting the 'in' parameter to 'body', but the documentation says I have to use requestBody now. Not terribly pleased with the results...functional, but not optimal.
Here's an example of a requestBody I'm using currently:
/**
*
* #OA\RequestBody(
* request="Answer",
* description="Answer object that needs to be added.",
* required=true,
* #OA\JsonContent(ref="#/components/schemas/Answer")
* )
*/
I suspect I need to do something with #mediaType, but when I try it, with a list of parameters, it doesn't give me anything 8(
What am I missing?
I was conflating the requestBody with the response...thought I'd need to send in json to get back json. Nope lol Just needed to send it with a form-data mediaType.
Here's what I ended up with, in case it helps someone:
/**
*
* #OA\RequestBody(
* request="Answer",
* description="Answer object that needs to be added.",
* required=true,
* #OA\MediaType(
* mediaType="multipart/form-data",
* #OA\Schema(ref="#/components/schemas/Answer")
* )
* )
*/

In Joomla, SEF Url Conversion query not get View and layout

I Newly to develop a Component with SEF Feature.
I Pass Following query for route.php
JRoute::_('index.php?com_example&view=profile&layout=item_interestonme&id='.$itemval["profile_id"]);
In route.php,
$query display Array ( [Itemid] => 114 [option] => com_example )
Only. view, layout, id not display. how to fix this issue.
There is a preprocess method in the Router-interface, defined like this:
/**
* Prepare-method for URLs
* This method is meant to validate and complete the URL parameters.
* For example it can add the Itemid or set a language parameter.
* This method is executed on each URL, regardless of SEF mode switched
* on or not.
*
* #param array $query An associative array of URL arguments
*
* #return array The URL arguments to use to assemble the subsequent URL.
*
* #since 3.3
*/
public function preprocess($query);
You could try to override this in route.php. Perhaps the display-parameter is stripped from the query in the default implementation?

JobExplorer.findRunningJobExecutions does not work correctly

In a project I use spring-batch, as a part of cleanup for processes that stuck I use
JobExplorer.findRunningJobExecutions(...)
but that function return empty set. After digging I found next problem: spring-batch use SQL like
SELECT E.JOB_EXECUTION_ID, ... from %PREFIX%JOB_EXECUTION E ... WHERE ... E.END_TIME is NULL .... After running long job, I got that from beginning 3 Dates in %PREFIX%JOB_EXECUTION (CREATE_TIME, START_TIME, END_TIME) have same value. This mean that SQL will always return empty set.
Question is, am I one who get this?
How to report bug to Spring team?
Here is the link to the Spring batch project home page
Jira's can be Entered here
Not sure what version you are running, but with version 2.1.1 (which is real old I know) but this code works.
jobOperator.getRunningExecutions(String jobName)
Here is the javadoc from that version
/**
* Get the id values of all the running {#link JobExecution JobExecutions}
* with the given job name.
*
* #param jobName the name of the job to search under
* #return the id values of the running {#link JobExecution} instances
* #throws NoSuchJobException if there are no {#link JobExecution
* JobExecutions} with that job name
*/
Set<Long> getRunningExecutions(String jobName) throws NoSuchJobException;
Link to the most update JobOperator
Hope this helps.

How are expired codeigniter sessions cleaned up?

Experts,
I'm trying to understand how sessions are cleaned up in Codeigniter in case the app is configured to store sessions in a database table.
In my case, I have three expired sessions in that session table and one active one for the same user. The manual states:
"Note: The Session class has built-in garbage collection which clears out expired sessions so you do not need to write your own routine to do it."
Hmm, so when are my 'old' session in the db session table being cleared out or am I missing something?
thanks!
Here's the relevant source code of the Session class:
/**
* Garbage collection
*
* This deletes expired session rows from database
* if the probability percentage is met
*
* #access public
* #return void
*/
function _sess_gc()
{
if ($this->sess_use_database != TRUE)
{
return;
}
srand(time());
if ((rand() % 100) < $this->gc_probability)
{
$expire = $this->now - $this->sess_expiration;
$this->CI->db->where("last_activity < {$expire}");
$this->CI->db->delete($this->sess_table_name);
log_message('debug', 'Session garbage collection performed.');
}
}
This function is called in one place, in the constructor of the Session class (almost the last line), so once per request under normal circumstances.
$this->gc_probability is hardcoded to 5 at the top of the class and it doesn't appear to be possible to change it. I'm not sure, but I believe this means that 5% of the time (randomly) the garbage collection will run, clearing out old entries from the sessions DB table.
Note that these old entries are of no significance or harm, the cleanup is only done so your database table does not get overloaded with old, useless records.

Resources