title: GCP - Message from PubSub to BigQuery
body: <p>I need to get the data from my pubsub message and insert into bigquery.</p>
  <p>What I have:</p>
  <pre><code>const topicName = &quot;-----topic-name-----&quot;;
  const data = JSON.stringify({ foo: &quot;bar&quot; });
  
  // Imports the Google Cloud client library
  const { PubSub } = require(&quot;@google-cloud/pubsub&quot;);
  
  // Creates a client; cache this for further use
  const pubSubClient = new PubSub();
  
  async function publishMessageWithCustomAttributes() {
    // Publishes the message as a string, e.g. &quot;Hello, world!&quot; or JSON.stringify(someObject)
    const dataBuffer = Buffer.from(data);
  
    // Add two custom attributes, origin and username, to the message
    const customAttributes = {
      origin: &quot;nodejs-sample&quot;,
      username: &quot;gcp&quot;,
    };
  
    const messageId = await pubSubClient
      .topic(topicName)
      .publish(dataBuffer, customAttributes);
    console.log(`Message ${messageId} published.`);
  }
  
  publishMessageWithCustomAttributes().catch(console.error);
  </code></pre>
  <p>I need to get the data/attributes from this message and query in BigQuery, anyone can help me?</p>
  <p>Thaks in advance!</p>