Execution sequence in Gatling

I have gatling simulation which consist of following code:

before {
    println("Before Test")
    // some code for cleanup

var feeder = Iterator.continually(Map("userId" -> fetchUserId()))

val login = http("Login")

def processPayload(): Body => ByteArrayBody =
(body: Body) => {
  val stream = body match {
    case b: CompositeByteArrayBody => {
      println("In payload processor")
      b.asStream.map(content => {
        println("Processing Payload")
        // Payload Processing Logic
        // Add time stamp to request body
        var payload = new String(content.readAllBytes()).replace("123123123123", TimeUtil.epochMilliSeconds().toString)
        // some other logic

I would like to understand few things:

  1. What is the execution sequence in Gatling. As execution of above code prints statements in follower order.

In payload processor

Before Test

It prints from fetchUserId()

Processing payload

Shouldn’t the beforeTest running before payloadProcessor?

  1. The time stamp is a critical information for our api requests. As server rejects all the requests which is having timestamp older than 60 seconds. In my case, the tests are running continuously for few minutes with user injection as constantUsersPerSec(someValue) during someDuration. What is the appropriate way of injecting timestamp in the request body?. In above shown code, the time stamp is getting updated in processRequestBody(processPayload()) block which becomes stale after few hits. The servers starts rejecting requests because of 60s check. I tried putting the timestamp thing in feeder but still it has same issue. I suspect that Gatling queues all the requests at once and start sending it as per the user injection profile, which makes my requests older that 60s. Am I right? Running above simulation only for a few seconds do not show such problem.